diff --git a/.ripr/traceability.toml b/.ripr/traceability.toml index a00a580dd8e..abdb86d2251 100644 --- a/.ripr/traceability.toml +++ b/.ripr/traceability.toml @@ -13054,6 +13054,10 @@ id = "RIPR-SPEC-0211" name = "MCP workspace session evidence" spec = "docs/specs/RIPR-SPEC-0211-mcp-workspace-session-evidence.md" tests = [ + "crates/ripr/tests/mcp_stdio.rs::refreshed_gap_filters_narrow_real_stdio_and_replay_bound_continuation", + "crates/ripr/src/mcp/workspace.rs::tests::gap_list_summaries_project_readiness_matching_get_gap", + "crates/ripr/src/mcp/workspace.rs::tests::gap_list_filters_narrow_each_dimension_then_combine_before_paging", + "crates/ripr/src/mcp/server_tests.rs::list_gaps_accepts_filters_at_the_dispatch_edge", "crates/ripr/tests/mcp_stdio.rs::pre_call_contract_discloses_committed_scope_on_wire_and_help", "crates/ripr/tests/mcp_stdio.rs::dirty_tree_cli_and_mcp_retain_their_distinct_inputs", "crates/ripr/src/mcp/workspace.rs::tests::complete_zero_and_incomplete_zero_stay_distinct", diff --git a/changelog.d/7694-mcp-gap-filters.md b/changelog.d/7694-mcp-gap-filters.md new file mode 100644 index 00000000000..adba38f28b3 --- /dev/null +++ b/changelog.d/7694-mcp-gap-filters.md @@ -0,0 +1,6 @@ + +- `ripr_list_gaps` narrows stored gaps by file, class, language, and repair + readiness before paging, with truthful counts and bound continuations. + Gap-list envelopes move from `ripr-mcp-gap-list-v1` to + `ripr-mcp-gap-list-v2` because the strict v1 schema rejects the added fields; + strict readers must rediscover the tool schema and accept v2 (#7464). diff --git a/crates/ripr/src/mcp/gaps.rs b/crates/ripr/src/mcp/gaps.rs index a3d488422e8..d71e9f03da5 100644 --- a/crates/ripr/src/mcp/gaps.rs +++ b/crates/ripr/src/mcp/gaps.rs @@ -12,7 +12,7 @@ use serde_json::{Value, json}; use sha2::{Digest, Sha256}; use std::path::Path; -pub(crate) const GAP_LIST_SCHEMA_VERSION: &str = "ripr-mcp-gap-list-v1"; +pub(crate) const GAP_LIST_SCHEMA_VERSION: &str = "ripr-mcp-gap-list-v2"; pub(crate) const GAP_SCHEMA_VERSION: &str = "ripr-mcp-gap-v1"; /// `ripr_get_gap` / `ripr://gap/{canonical_id}` never authorizes an @@ -178,9 +178,20 @@ pub(crate) struct GapItem { pub(crate) canonical_id: String, pub(crate) finding_id: String, pub(crate) file: String, + /// Exposure class wire token (`exposed`, `weakly_exposed`, ...) captured + /// at projection time, so list filters re-read stored facts (#7464). + class: String, + /// Language wire string (`rust`, `python`, ...) or `None` when the + /// producer populated no language; stored for the same filter route. + language: Option, /// Small deterministic document used by `ripr_list_gaps`; its serialized - /// byte length is the item's budget payload bytes. Class, language, and - /// line live here (and in the evidence core), not as duplicated fields. + /// byte length is the item's budget payload bytes. It projects stored + /// class/language facts and the source line alongside the evidence core. + /// The summary also carries the commit-time repair-readiness projection + /// (`repair_packet_ready` plus the typed first-failing-gate + /// `repair_ineligibility`, null when ready), so agents can sort + /// actionable items without one `ripr_get_gap` call per candidate + /// (#7464). pub(crate) list_summary: Value, list_summary_bytes: usize, /// Complete bounded evidence document (without the per-request snapshot @@ -221,22 +232,26 @@ impl GapItem { .map(|language| language.as_str().to_string()); let line = finding.probe.location.line; + let repair_readiness = RepairReadiness::from_finding(finding, root); let list_summary = json!({ "canonical_id": canonical_id, "class": class, "language": language, "file": file, "line": line, + "repair_packet_ready": repair_readiness.ready, + "repair_ineligibility": repair_readiness.ineligibility, }); let list_summary_bytes = serialized_bytes(&list_summary)?; let evidence_core = gap_evidence_core(finding, &canonical_id, root)?; let (evidence_bytes, evidence_sha256) = serialized_evidence_identity(&evidence_core)?; - let repair_readiness = RepairReadiness::from_finding(finding, root); Ok(Self { canonical_id, finding_id: finding.id.clone(), file, + class, + language, list_summary, list_summary_bytes, evidence_core, @@ -247,6 +262,21 @@ impl GapItem { }) } + pub(crate) fn class(&self) -> &str { + &self.class + } + + pub(crate) fn language(&self) -> Option<&str> { + self.language.as_deref() + } + + /// Commit-time repair readiness: `true` only when every producer gate + /// was established. Matches the `readiness.repair_packet_ready` fact the + /// same item's `ripr_get_gap` document reports (#7464). + pub(crate) fn repair_ready(&self) -> bool { + self.repair_readiness.ready + } + pub(crate) fn list_summary_bytes(&self) -> usize { self.list_summary_bytes } diff --git a/crates/ripr/src/mcp/protocol.rs b/crates/ripr/src/mcp/protocol.rs index 60e042dd8c7..56e2a8264cb 100644 --- a/crates/ripr/src/mcp/protocol.rs +++ b/crates/ripr/src/mcp/protocol.rs @@ -68,7 +68,7 @@ const STATUS_TOOL_DESCRIPTION: &str = "Report the RIPR workspace and session sta const REFRESH_TOOL_DESCRIPTION: &str = "Run one bounded static analysis of the committed default-branch diff through RIPR's shared check authority and commit the completed snapshot into this server's session. In this snapshot, staged and unstaged tracked edits and untracked files are outside the analyzed scope. `ripr check` defaults to the working tree when staged or unstaged tracked edits exist; shared check authority does not mean identical input. Use `ripr check --committed` for committed input, or `ripr check --worktree --format json` for staged and unstaged tracked edits outside MCP. The call blocks until the attempt reaches a terminal state and reports the attempt state: completed (a snapshot identity is returned, bound to the typed AnalysisOutcome), failed (a typed failure code, bounded detail, and recovery; the last-known-good snapshot is kept), in_flight (a concurrent attempt is running; poll ripr_workspace_status), or workspace_unavailable (the root was not usable; restart the server with `--root `). An attempt runs to a terminal state; cancelling the MCP request never rolls an attempt back or manufactures a snapshot. A cancelled attempt still commits as a completed snapshot when it finishes and only transport teardown abandons one before it commits, while a superseded attempt is never committed. Bounded analysis: the workspace's own ripr.toml is honored through the same resolution the CLI uses (a loaded config, built-in defaults with marker-based language auto-enable when none resolves, draft mode); a configuration that cannot be read or resolved fails the attempt closed with config_invalid. This tool never edits source, executes verification or mutation commands, or prepares a repair. Recovery vocabulary: analysis_failed (retry; run `ripr check --format json` for the full diagnostic), unsupported_profile (narrow the diff), config_invalid (resolve the workspace configuration error the failure names), plus reserved codes (workspace_ambiguous, static_limitation, cancelled, superseded) owned by later slices."; -const LIST_GAPS_TOOL_DESCRIPTION: &str = "Return the deterministic bounded working set of canonical items for the current completed snapshot (or for an explicitly named snapshot_id, which must match the current one or the call fails closed with stale_snapshot and the current identity). The response contains total, eligible, selected, and omitted counts; selected and complete serialized bytes; every omitted identity with its reason; the snapshot/profile/budget identity and selection basis; and one small summary per selected item (canonical_id, exposure class, language, file, line). Selection is the shared CLI/LSP budget authority over the snapshot's canonical items; MCP does not re-rank, never truncates silently, and infers no business risk. Overflow is disclosed with reasons and the omitted identities. offset and limit page over the selected items in snapshot order; when the whole selection cannot fit one wire response, the call returns the first wire-fitting page and discloses the window through page.has_more and page.next_offset, so walk next_offset to read the rest — the continuation routes are the next page and ripr_get_gap. Before the first successful ripr_refresh on a usable root this tool fails closed with no_snapshot; unavailable roots fail closed with workspace_unavailable and recovery to restart the server with `ripr mcp --stdio --root `; while an attempt runs it reports analysis_in_flight; only a document that cannot fit even one page fails with result_too_large. Summaries carry no evidence detail; read one item with ripr_get_gap."; +const LIST_GAPS_TOOL_DESCRIPTION: &str = "Return the deterministic bounded working set of canonical items for the current completed snapshot (or for an explicitly named snapshot_id, which must match the current one or the call fails closed with stale_snapshot and the current identity). The response contains total, eligible, selected, filtered, and omitted counts; selected and complete serialized bytes; every omitted identity with its reason; the snapshot/profile/budget identity and selection basis; the echoed filters; and one small summary per selected item (canonical_id, exposure class, language, file, line, plus the commit-time repair_packet_ready projection with its typed repair_ineligibility reason, null when ready; ripr_get_gap carries the same ready fact with the human reason sentence instead of the typed code). Selection is the shared CLI/LSP budget authority over the snapshot's canonical items; MCP does not re-rank, never truncates silently, and infers no business risk. Overflow is disclosed with reasons and the omitted identities. Optional file, class, language, and repair_ready narrow the stored selection over already-projected commit-time facts before paging (conjunctive; file matches exact, prefix, or trailing-segment paths after `./` normalization), so offset and limit page the narrowed set — one bounded call answers which items touch one file or which are repair-ready, with no per-item ripr_get_gap walk. offset and limit page over the narrowed items in snapshot order; when the whole narrowed set cannot fit one wire response, the call returns the first wire-fitting page and discloses the window through page.has_more and page.next_offset, so walk next_offset to read the rest — the continuation routes are the next page (with the filters pinned) and ripr_get_gap. Before the first successful ripr_refresh on a usable root this tool fails closed with no_snapshot; unavailable roots fail closed with workspace_unavailable and recovery to restart the server with `ripr mcp --stdio --root `; while an attempt runs it reports analysis_in_flight; only a document that cannot fit even one page fails with result_too_large. Summaries carry no evidence detail beyond the readiness projection; read one item with ripr_get_gap for complete evidence."; const GET_GAP_TOOL_DESCRIPTION: &str = "Return one canonical item's complete bounded evidence from the current completed snapshot (optional snapshot_id must match the current snapshot or the call fails closed with stale_snapshot). The document binds the item to its snapshot identity and contains: identity and location; the changed behavior (expression, before/after, delta kind, probe family); causal attribution (canonical gap owner, behavior kind, probe kind, normalized discriminator); discriminator availability and the producer's observed/missing evidence; related tests with oracle kind and strength; readiness, whose repair_packet_ready now reports the committed producer repair-readiness facts (candidate actionability, an established discriminator, and a strong directly-related test fix site on a test surface) with the typed first-failing-gate reason when not ready — this evidence never authorizes an edit by itself; a repair boundary of none_declared until ripr_prepare_repair binds a transaction; and links to the snapshot resource and — once a session transaction exists for this item — the repair-attempt resource. Unknown ids fail closed with item_not_found; a document over the response bound fails with result_too_large and recovery to ripr check --committed --format json outside MCP — a bounded summary of the committed diff whose related tests cap per finding and whose findings array can omit findings — because retrying ripr_get_gap cannot shrink the item. Before the first successful ripr_refresh on a usable root this tool fails closed with no_snapshot; unavailable roots fail closed with workspace_unavailable and recovery to restart the server with `ripr mcp --stdio --root `; while an attempt runs it reports analysis_in_flight. Equivalent evidence reads: the tool ripr_get_gap and the resource ripr://gap/{canonical_id} return the same document."; @@ -453,12 +453,31 @@ fn list_gaps_tool_descriptor() -> Value { "offset": { "type": "integer", "minimum": 0, - "description": "Start index within the selected items, in snapshot order. Default 0." + "description": "Start index within the narrowed items, in snapshot order. Default 0." }, "limit": { "type": "integer", "minimum": 1, - "description": "Maximum selected-item summaries to return in this page." + "description": "Maximum narrowed-item summaries to return in this page." + }, + "file": { + "type": "string", + "minLength": 1, + "description": "Narrow to items whose workspace-relative file equals, prefixes, or trailing-matches this path (one leading `./` is ignored on both sides)." + }, + "class": { + "type": "string", + "minLength": 1, + "description": "Narrow to one exposure-class wire token (for example `exposed` or `weakly_exposed`)." + }, + "language": { + "type": "string", + "minLength": 1, + "description": "Narrow to one language wire string (for example `rust` or `python`)." + }, + "repair_ready": { + "type": "boolean", + "description": "Narrow to repair-ready items (true) or not-ready items (false), using the commit-time readiness projection." } }, "additionalProperties": false @@ -1027,6 +1046,18 @@ fn gap_list_output_schema() -> Value { "total": { "type": "integer", "minimum": 0 }, "eligible": { "type": "integer", "minimum": 0 }, "selected": { "type": "integer", "minimum": 0 }, + "filtered": { "type": "integer", "minimum": 0 }, + "filters": { + "type": "object", + "properties": { + "file": { "type": ["string", "null"] }, + "class": { "type": ["string", "null"] }, + "language": { "type": ["string", "null"] }, + "repair_ready": { "type": ["boolean", "null"] } + }, + "required": ["file", "class", "language", "repair_ready"], + "additionalProperties": false + }, "omitted": { "type": "integer", "minimum": 0 }, "selected_bytes": { "type": "integer", "minimum": 0 }, "complete_bytes": { "type": "integer", "minimum": 0 }, @@ -1081,6 +1112,8 @@ fn gap_list_output_schema() -> Value { "total", "eligible", "selected", + "filtered", + "filters", "omitted", "selected_bytes", "complete_bytes", @@ -1281,7 +1314,7 @@ mod tests { -> Result<(), String> { let rows = |count: usize| { json!({ - "schema_version": "ripr-mcp-gap-list-v1", + "schema_version": "ripr-mcp-gap-list-v2", "rows": (0..count) .map(|index| { json!({ @@ -1321,7 +1354,7 @@ mod tests { } let reparsed: Value = serde_json::from_str(small_text) .map_err(|error| format!("text copy is not JSON: {error}"))?; - if reparsed.get("schema_version") != Some(&json!("ripr-mcp-gap-list-v1")) { + if reparsed.get("schema_version") != Some(&json!("ripr-mcp-gap-list-v2")) { return Err(format!("text copy drifted from the document: {reparsed}")); } diff --git a/crates/ripr/src/mcp/server.rs b/crates/ripr/src/mcp/server.rs index 7c6b8d5a931..4a8b718e00b 100644 --- a/crates/ripr/src/mcp/server.rs +++ b/crates/ripr/src/mcp/server.rs @@ -162,10 +162,25 @@ impl McpServer { &self, arguments: Option>, ) -> Result { - reject_unknown_arguments(&arguments, &["snapshot_id", "offset", "limit"])?; + reject_unknown_arguments( + &arguments, + &[ + "snapshot_id", + "offset", + "limit", + "file", + "class", + "language", + "repair_ready", + ], + )?; let requested = optional_string_argument(&arguments, "snapshot_id")?; let offset = optional_nonnegative_argument(&arguments, "offset")?; let limit = optional_positive_argument(&arguments, "limit")?; + let file = optional_nonempty_string_argument(&arguments, "file")?; + let class = optional_nonempty_string_argument(&arguments, "class")?; + let language = optional_nonempty_string_argument(&arguments, "language")?; + let repair_ready = optional_bool_argument(&arguments, "repair_ready")?; let session = self.session.lock().await; match session.list_gaps( requested.as_deref(), @@ -173,6 +188,12 @@ impl McpServer { offset: offset.unwrap_or(0), limit, }, + &workspace::GapListFilter { + file, + class, + language, + repair_ready, + }, ) { Ok(document) => self.bounded_tool_result( document, @@ -461,6 +482,40 @@ fn optional_string_argument( } } +/// A filter string (#7464): a non-empty JSON string. Empty strings stay +/// invalid params instead of silently matching nothing or everything. +fn optional_nonempty_string_argument( + arguments: &Option>, + name: &str, +) -> Result, ErrorData> { + match optional_string_argument(arguments, name)? { + Some(value) if value.is_empty() => Err(ErrorData::invalid_params( + format!("{name} must be a non-empty string"), + None, + )), + other => Ok(other), + } +} + +/// A `repair_ready` selector (#7464): a JSON boolean. Strings, integers and +/// nulls stay invalid params instead of silently coercing. +fn optional_bool_argument( + arguments: &Option>, + name: &str, +) -> Result, ErrorData> { + let Some(arguments) = arguments else { + return Ok(None); + }; + match arguments.get(name) { + None => Ok(None), + Some(Value::Bool(value)) => Ok(Some(*value)), + Some(_other) => Err(ErrorData::invalid_params( + format!("{name} must be a boolean"), + None, + )), + } +} + /// A paging offset (#6021): a JSON integer `>= 0`. Booleans, floats, /// strings and negatives stay invalid params instead of silently coercing. fn optional_nonnegative_argument( diff --git a/crates/ripr/src/mcp/server_tests.rs b/crates/ripr/src/mcp/server_tests.rs index d2eaf2f3a51..e294e5dc323 100644 --- a/crates/ripr/src/mcp/server_tests.rs +++ b/crates/ripr/src/mcp/server_tests.rs @@ -447,6 +447,79 @@ async fn list_gaps_accepts_offset_and_limit_at_the_dispatch_edge() -> Result<(), Ok(()) } +#[tokio::test] +async fn list_gaps_accepts_filters_at_the_dispatch_edge() -> Result<(), String> { + // #7464: filter arguments are part of the input contract. A pre-refresh + // server answers past dispatch with typed `no_snapshot` — proving the + // arguments were accepted — while malformed values stay invalid params. + let server = healthy_server()?; + for arguments in [ + serde_json::json!({"file": "src/checkout.rs"}), + serde_json::json!({"class": "weakly_exposed"}), + serde_json::json!({"language": "rust"}), + serde_json::json!({"repair_ready": true}), + serde_json::json!({"repair_ready": false}), + serde_json::json!({ + "file": "src/checkout.rs", + "class": "weakly_exposed", + "language": "rust", + "repair_ready": true, + "offset": 0, + "limit": 10, + }), + ] { + let arguments = serde_json::from_value(arguments).map_err(|error| error.to_string())?; + let response = server + .list_gaps_tool(arguments) + .await + .map_err(|error| format!("dispatch must accept filter arguments: {error:?}"))?; + let result = match response { + rmcp::model::CallToolResponse::Complete(result) => result, + other => { + return Err(format!( + "accepted filter arguments must reach the typed failure, got {other:?}" + )); + } + }; + let value = serde_json::to_value(result).map_err(|error| error.to_string())?; + if value + .pointer("/structuredContent/failure/code") + .and_then(serde_json::Value::as_str) + != Some(workspace::CODE_NO_SNAPSHOT) + { + return Err(format!("filtered call lost no_snapshot: {value}")); + } + } + for arguments in [ + serde_json::json!({"file": ""}), + serde_json::json!({"file": 7}), + serde_json::json!({"file": null}), + serde_json::json!({"class": ""}), + serde_json::json!({"class": null}), + serde_json::json!({"language": 7}), + serde_json::json!({"repair_ready": "true"}), + serde_json::json!({"repair_ready": 1}), + serde_json::json!({"repair_ready": null}), + serde_json::json!({"repairReady": true}), + ] { + let arguments = serde_json::from_value(arguments).map_err(|error| error.to_string())?; + match server.list_gaps_tool(arguments).await { + Err(error) if error.code == rmcp::model::ErrorCode::INVALID_PARAMS => {} + Ok(response) => { + return Err(format!( + "list_gaps must reject malformed filter arguments with invalid params: {response:?}" + )); + } + Err(error) => { + return Err(format!( + "list_gaps must reject malformed filter arguments with invalid params, got {error:?}" + )); + } + } + } + Ok(()) +} + #[tokio::test] async fn get_gap_rejects_bad_arguments_at_the_dispatch_edge() -> Result<(), String> { let server = McpServer::new(WorkspaceStatus::resolve_with_root(None).0, None) diff --git a/crates/ripr/src/mcp/workspace.rs b/crates/ripr/src/mcp/workspace.rs index 73c3b6cf72c..1c82def7800 100644 --- a/crates/ripr/src/mcp/workspace.rs +++ b/crates/ripr/src/mcp/workspace.rs @@ -84,6 +84,113 @@ pub(crate) struct GapListWindow { pub(crate) limit: Option, } +/// Caller-narrowed filters over already-projected commit-time facts +/// (#7464): `file` (exact, prefix, or trailing-segment match after `./` +/// normalization), `class` (exposure-class wire token), `language` (language +/// wire string), and `repair_ready` (the commit-time repair-readiness +/// projection). Filters combine by conjunction and apply between the stored +/// budget selection and page fill, so `offset`/`limit` page the narrowed set. +/// Filtering re-reads stored projection facts; it never re-runs analysis, +/// re-ranks, or widens the selection past the budget. +#[derive(Clone, Debug, Default, Eq, PartialEq)] +pub(crate) struct GapListFilter { + pub(crate) file: Option, + pub(crate) class: Option, + pub(crate) language: Option, + pub(crate) repair_ready: Option, +} + +impl GapListFilter { + fn matches(&self, item: &GapItem) -> bool { + if let Some(class) = self.class.as_deref() + && item.class() != class + { + return false; + } + if let Some(language) = self.language.as_deref() + && item.language() != Some(language) + { + return false; + } + if let Some(ready) = self.repair_ready + && item.repair_ready() != ready + { + return false; + } + if let Some(file) = self.file.as_deref() + && !gap_file_matches(item.file.as_str(), file) + { + return false; + } + true + } + + /// Echo of the caller-narrowed filters for the list document: each + /// dimension carries its requested value or null when unfiltered. + fn document(&self) -> Value { + json!({ + "file": self.file, + "class": self.class, + "language": self.language, + "repair_ready": self.repair_ready, + }) + } + + /// Filter arguments for the bound `next_page` continuation, so walking + /// the narrowed set resumes with the same filters pinned. + fn arguments(&self) -> Value { + let mut arguments = serde_json::Map::new(); + if let Some(file) = self.file.as_deref() { + arguments.insert("file".to_string(), Value::from(file)); + } + if let Some(class) = self.class.as_deref() { + arguments.insert("class".to_string(), Value::from(class)); + } + if let Some(language) = self.language.as_deref() { + arguments.insert("language".to_string(), Value::from(language)); + } + if let Some(ready) = self.repair_ready { + arguments.insert("repair_ready".to_string(), Value::from(ready)); + } + Value::Object(arguments) + } +} + +/// File-filter matching over workspace-relative item files (#7464). Both +/// sides shed one leading `./` (the shared finding-location owner renders +/// `./`-prefixed paths while callers usually pass bare ones). A filter then +/// matches when it equals the item file, prefixes it at a `/` boundary, or +/// suffixes it at a `/` boundary (a bare `checkout.rs` or `src/checkout.rs` +/// still narrows to that path without scanning every page). +fn gap_file_matches(item_file: &str, filter: &str) -> bool { + let item = item_file.strip_prefix("./").unwrap_or(item_file); + let filter = filter.strip_prefix("./").unwrap_or(filter); + if filter.is_empty() { + return false; + } + item == filter + || item.strip_prefix(filter).is_some_and(|rest| { + // A prefix matches at a segment boundary: either the next item + // character is `/`, or the filter itself ends there (so `src/` + // narrows to everything under it). A partial segment such as + // `src/check` never matches. + rest.starts_with('/') || filter.ends_with('/') + }) + || item + .strip_suffix(filter) + .is_some_and(|prefix| prefix.ends_with('/')) +} + +/// The narrowed-list scope one gap-list document discloses: the stored +/// budget selection, the caller-named snapshot binding, the echoed filter, +/// and the narrowed-set count the page walks (#7464). +struct GapListScope<'a> { + selection: &'a DiagnosticBudgetResult, + requested: Option<&'a str>, + filter: &'a GapListFilter, + filtered: usize, +} + /// The disclosed page window inside a gap-list document: what the caller /// asked for (`offset`, `limit` when set), what shipped, and how to /// continue. A page never lies about the selection: `selected` stays the @@ -493,15 +600,17 @@ impl WorkspaceSession { /// Bounded working set for the current (or named) snapshot. Selection is /// the snapshot's stored shared-budget result; this function never - /// re-runs ranking. `window` pages over the selected items in snapshot - /// order (#6021); an unset limit byte-fills the page to - /// [`super::MAX_TOOL_DOCUMENT_BYTES`] so a listing that outgrows one - /// wire response degrades to disclosed pages instead of failing after - /// budget approval. + /// re-runs ranking. `filter` narrows the stored selection over + /// already-projected commit-time facts (#7464) before `window` pages over + /// the narrowed items in snapshot order (#6021); an unset limit + /// byte-fills the page to [`super::MAX_TOOL_DOCUMENT_BYTES`] so a + /// listing that outgrows one wire response degrades to disclosed pages + /// instead of failing after budget approval. pub(crate) fn list_gaps( &self, requested: Option<&str>, window: GapListWindow, + filter: &GapListFilter, ) -> Result { let snapshot = self.active_snapshot(requested)?; let selection = &snapshot.selection; @@ -512,20 +621,26 @@ impl WorkspaceSession { .items .iter() .filter(|item| selected_ids.contains(item.canonical_id.as_str())) + .filter(|item| filter.matches(item)) .collect::>(); + // `filtered` counts the narrowed set the page walks; the budget-level + // `selected` count stays the full stored selection so the document + // never lies about what filtering removed. + let filtered = selected_items.len(); // The document shell carries every disclosure except the page of // item summaries; its measured size sets the page budget. The // reserve absorbs the small byte difference between this shell's // zeroed page fields and the filled ones the caller receives. let shell_bytes = { - let shell = self.gap_list_document( - snapshot, + let scope = GapListScope { selection, requested, - Vec::new(), - &GapPage::default(), - )?; + filter, + filtered, + }; + let shell = + self.gap_list_document(snapshot, &scope, Vec::new(), &GapPage::default())?; document_bytes(&shell)? }; // Reserve covers the array syntax around the summaries and the @@ -572,10 +687,15 @@ impl WorkspaceSession { }; if !items.is_empty() { let structured_fit = |count: usize| -> Result { - let probe = self.gap_list_document( - snapshot, + let scope = GapListScope { selection, requested, + filter, + filtered, + }; + let probe = self.gap_list_document( + snapshot, + &scope, items[..count].to_vec(), &page_fields(count), )?; @@ -620,7 +740,13 @@ impl WorkspaceSession { let page = page_fields(items.len()); - let document = self.gap_list_document(snapshot, selection, requested, items, &page)?; + let scope = GapListScope { + selection, + requested, + filter, + filtered, + }; + let document = self.gap_list_document(snapshot, &scope, items, &page)?; // A listing whose non-pageable shell (for example an omission // disclosure alone) outgrows the ceiling cannot be narrowed by // paging; fail closed naming the identity route (#6021). @@ -640,35 +766,47 @@ impl WorkspaceSession { } /// Assemble the gap-list document around a page of item summaries. + /// The scope carries the caller-narrowed filter echoed verbatim and the + /// narrowed-set count the page walks, while `selected` stays the full + /// stored-selection count so the document never lies about what + /// filtering removed (#7464). fn gap_list_document( &self, snapshot: &Snapshot, - selection: &DiagnosticBudgetResult, - requested: Option<&str>, + scope: &GapListScope<'_>, items: Vec, page: &GapPage, ) -> Result { + let selection = scope.selection; + let filter = scope.filter; let mut continuation = json!({ "tool": "ripr_get_gap", "resource_template": "ripr://gap/{canonical_id}", }); if let Some(next_offset) = page.next_offset { - // The generated route pins the snapshot identity: a refresh - // between pages fails closed with stale_snapshot instead of - // silently resuming at the old offset over a new selection - // (#6021 review). + // The generated route pins the snapshot identity and the caller + // filters: a refresh between pages fails closed with + // stale_snapshot instead of silently mixing snapshots, and the + // narrowed walk resumes narrowed (#6021 review, #7464). + let mut arguments = json!({ + "snapshot_id": snapshot.snapshot_id, + "offset": next_offset, + }); + for (name, value) in filter.arguments().as_object().cloned().unwrap_or_default() { + arguments[name] = value; + } + if let Some(limit) = page.limit { + arguments["limit"] = json!(limit); + } continuation["next_page"] = json!({ "tool": "ripr_list_gaps", - "arguments": { - "snapshot_id": snapshot.snapshot_id, - "offset": next_offset, - }, + "arguments": arguments, }); } Ok(json!({ "schema_version": GAP_LIST_SCHEMA_VERSION, "snapshot_id": snapshot.snapshot_id, - "requested_snapshot_id": requested, + "requested_snapshot_id": scope.requested, "snapshot_profile_budget_identity": selection.snapshot_profile_budget_identity, "selection_basis_version": selection.selection_basis_version, "budget": { @@ -680,6 +818,8 @@ impl WorkspaceSession { "total": selection.total_canonical_items, "eligible": selection.eligible_items, "selected": selection.selected.len(), + "filtered": scope.filtered, + "filters": filter.document(), "omitted": selection.omitted.len(), "selected_bytes": selection.selected_bytes, "complete_bytes": selection.complete_bytes, @@ -706,9 +846,9 @@ impl WorkspaceSession { })) .collect::>(), "continuation": continuation, - "claim_boundary": "Bounded working-set projection over one completed snapshot. Selection is the shared CLI/LSP budget authority; omitted identities and reasons are disclosed, never silently truncated, and no business-risk ranking is inferred.", + "claim_boundary": "Bounded working-set projection over one completed snapshot. Selection is the shared CLI/LSP budget authority; omitted identities and reasons are disclosed, never silently truncated, and no business-risk ranking is inferred. Filters narrow the stored selection over commit-time facts before paging; they never widen it.", "limitations": [ - "summaries do not contain evidence detail; read one item with ripr_get_gap or ripr://gap/{canonical_id}", + "summaries carry identity, location, and the commit-time repair-readiness projection only; read one item with ripr_get_gap or ripr://gap/{canonical_id} for complete evidence", "the list is deterministic for its snapshot identity; a refresh replaces the snapshot and its identities", ], })) @@ -1325,10 +1465,10 @@ mod tests { superseded_order: std::collections::VecDeque::new(), }; let _ = complete - .list_gaps(None, GapListWindow::default()) + .list_gaps(None, GapListWindow::default(), &GapListFilter::default()) .map_err(|failure| failure.detail)?; let incomplete_doc = incomplete - .list_gaps(None, GapListWindow::default()) + .list_gaps(None, GapListWindow::default(), &GapListFilter::default()) .map_err(|failure| failure.detail)?; let complete_snapshot = complete .last_good @@ -1378,7 +1518,7 @@ mod tests { fn list_get_snapshot_before_any_refresh_fail_closed() -> Result<(), String> { let session = WorkspaceSession::default(); expect_code( - session.list_gaps(None, GapListWindow::default()), + session.list_gaps(None, GapListWindow::default(), &GapListFilter::default()), CODE_NO_SNAPSHOT, )?; expect_code(session.get_gap("gap:any", None), CODE_NO_SNAPSHOT)?; @@ -1400,7 +1540,7 @@ mod tests { ..Default::default() }; expect_code( - session.list_gaps(None, GapListWindow::default()), + session.list_gaps(None, GapListWindow::default(), &GapListFilter::default()), CODE_ANALYSIS_IN_FLIGHT, )?; expect_code(session.get_gap("gap:any", None), CODE_ANALYSIS_IN_FLIGHT)?; @@ -1424,7 +1564,11 @@ mod tests { .ok_or_else(|| "missing snapshot".to_string())? .snapshot_id .clone(); - match session.list_gaps(Some("snapshot:sha256:old"), GapListWindow::default()) { + match session.list_gaps( + Some("snapshot:sha256:old"), + GapListWindow::default(), + &GapListFilter::default(), + ) { Ok(value) => Err(format!("stale snapshot must fail closed: {value}")), Err(failure) if failure.code != CODE_STALE_SNAPSHOT => { Err(format!("unexpected failure code: {}", failure.code)) @@ -1502,6 +1646,410 @@ mod tests { }) } + /// A session with four deterministically varied canonical items for the + /// #7464 filter proof: distinct files, classes, languages, and + /// commit-time repair readiness. No analysis runs. + fn session_with_varied_findings() -> Result { + let mut ready = gaps::test_finding()?; + ready.id = "finding:test:ready".to_string(); + if let Some(gap) = ready.canonical_gap.as_mut() { + gap.id = "gap:test:ready".to_string(); + } + ready.probe.id = crate::domain::ProbeId("probe:test:ready".to_string()); + ready.probe.location = crate::domain::SourceLocation::new("src/checkout.rs", 12, 5); + + let mut exposed_python = gaps::test_finding()?; + exposed_python.id = "finding:test:exposed-python".to_string(); + if let Some(gap) = exposed_python.canonical_gap.as_mut() { + gap.id = "gap:test:exposed-python".to_string(); + } + exposed_python.probe.id = crate::domain::ProbeId("probe:test:exposed-python".to_string()); + exposed_python.probe.location = crate::domain::SourceLocation::new("src/cart.py", 7, 1); + exposed_python.class = crate::domain::ExposureClass::Exposed; + exposed_python.language = Some(crate::domain::LanguageId::Python); + + let mut unready = gaps::test_finding()?; + unready.id = "finding:test:unready".to_string(); + unready.canonical_gap = None; + unready.probe.id = crate::domain::ProbeId("probe:test:unready".to_string()); + unready.probe.location = crate::domain::SourceLocation::new("src/checkout.rs", 30, 1); + unready.class = crate::domain::ExposureClass::ReachableUnrevealed; + + let mut unlocalized = gaps::test_finding()?; + unlocalized.id = "finding:test:unlocalized".to_string(); + if let Some(gap) = unlocalized.canonical_gap.as_mut() { + gap.id = "gap:test:unlocalized".to_string(); + } + unlocalized.probe.id = crate::domain::ProbeId("probe:test:unlocalized".to_string()); + unlocalized.probe.location = crate::domain::SourceLocation::new("src/limits.rs", 3, 1); + unlocalized.class = crate::domain::ExposureClass::NoStaticPath; + unlocalized.language = None; + + let findings = vec![ready, exposed_python, unready, unlocalized]; + let output = crate::app::CheckOutput { + schema_version: crate::app::CHECK_OUTPUT_SCHEMA_VERSION.to_string(), + harness_projections: Vec::new(), + tool: "ripr".to_string(), + mode: crate::app::Mode::Draft, + root: PathBuf::from("."), + base: None, + analysis_outcome: Some(outcome( + AnalysisOutcomeKind::CompleteWithFindings, + findings.len() as u64, + Vec::new(), + )?), + summary: crate::domain::Summary::default(), + findings, + preview_language_advisories: Vec::new(), + language_runs: Vec::new(), + no_scope_provided: false, + unanalyzed_working_tree: false, + untracked_working_tree_source_paths: Vec::new(), + unlinked_python_tests: None, + suppression: None, + partial_scope: None, + analyzed_revisions: None, + }; + let snapshot = Snapshot::from_output(&output, Some("root:sha256:test")) + .map_err(|failure| failure.detail)?; + Ok(WorkspaceSession { + in_flight: false, + last_good: Some(Arc::new(snapshot)), + last_failure: None, + workspace_failure: None, + repairs: std::collections::BTreeMap::new(), + superseded_attempts: std::collections::BTreeMap::new(), + superseded_order: std::collections::VecDeque::new(), + }) + } + + fn gap_ids(document: &Value) -> Result, String> { + document + .pointer("/items") + .and_then(Value::as_array) + .ok_or_else(|| "list lost its items array".to_string())? + .iter() + .map(|item| { + item.pointer("/canonical_id") + .and_then(Value::as_str) + .map(str::to_string) + .ok_or_else(|| "item summary lost its identity".to_string()) + }) + .collect() + } + + /// #7464: every list summary projects the commit-time repair-readiness + /// fact, and the projected `repair_packet_ready` bit matches the same + /// item's `ripr_get_gap` readiness block — so agents can sort actionable + /// items without one evidence call per candidate. + #[test] + fn gap_list_summaries_project_readiness_matching_get_gap() -> Result<(), String> { + let session = session_with_varied_findings()?; + let document = session + .list_gaps(None, GapListWindow::default(), &GapListFilter::default()) + .map_err(|failure| failure.detail)?; + if document.pointer("/selected").and_then(Value::as_u64) != Some(4) { + return Err(format!("varied fixture must select four items: {document}")); + } + let items = document + .pointer("/items") + .and_then(Value::as_array) + .ok_or_else(|| "list lost its items array".to_string())?; + for item in items { + let id = item + .pointer("/canonical_id") + .and_then(Value::as_str) + .ok_or_else(|| "item summary lost its identity".to_string())?; + let summary_ready = item + .pointer("/repair_packet_ready") + .and_then(Value::as_bool) + .ok_or_else(|| format!("summary {id} lost its readiness projection"))?; + let ineligibility = item + .get("repair_ineligibility") + .ok_or_else(|| format!("summary {id} lost its ineligibility projection"))?; + if summary_ready != ineligibility.is_null() { + return Err(format!( + "summary {id} must carry a null ineligibility exactly when ready: {item}" + )); + } + let gap = session + .get_gap(id, None) + .map_err(|failure| failure.detail)?; + let gap_ready = gap + .pointer("/item/readiness/repair_packet_ready") + .and_then(Value::as_bool) + .ok_or_else(|| format!("gap {id} lost its readiness block"))?; + if summary_ready != gap_ready { + return Err(format!( + "summary readiness ({summary_ready}) must match get_gap ({gap_ready}) for {id}" + )); + } + } + let by_id = |id: &str| { + items + .iter() + .find(|item| item.pointer("/canonical_id").and_then(Value::as_str) == Some(id)) + .ok_or_else(|| format!("missing summary {id}")) + }; + if by_id("gap:test:ready")?.pointer("/repair_packet_ready") != Some(&Value::Bool(true)) + || by_id("gap:test:ready")?.get("repair_ineligibility") != Some(&Value::Null) + { + return Err( + "the established finding must project ready with null ineligibility".to_string(), + ); + } + if by_id("finding:test:unready")?.pointer("/repair_packet_ready") + != Some(&Value::Bool(false)) + || by_id("finding:test:unready")? + .pointer("/repair_ineligibility") + .and_then(Value::as_str) + != Some("discriminator_not_populated_for_language") + { + return Err(format!( + "the gapless finding must project the typed refusal: {}", + by_id("finding:test:unready")? + )); + } + Ok(()) + } + + /// #7464: each filter dimension narrows the stored selection on its own, + /// dimensions combine conjunctively, and `offset`/`limit` page the + /// narrowed set — while `selected` stays the full stored-selection count + /// and `filters` echoes the request. + #[test] + fn gap_list_filters_narrow_each_dimension_then_combine_before_paging() -> Result<(), String> { + let session = session_with_varied_findings()?; + let filtered = |filter: &GapListFilter| { + session + .list_gaps(None, GapListWindow::default(), filter) + .map_err(|failure| failure.detail) + }; + let file = |value: &str| GapListFilter { + file: Some(value.to_string()), + ..Default::default() + }; + let class = |value: &str| GapListFilter { + class: Some(value.to_string()), + ..Default::default() + }; + let language = |value: &str| GapListFilter { + language: Some(value.to_string()), + ..Default::default() + }; + let ready = |value: bool| GapListFilter { + repair_ready: Some(value), + ..Default::default() + }; + + // One dimension at a time. + let cases: &[(&str, GapListFilter, &[&str])] = &[ + ("class", class("exposed"), &["gap:test:exposed-python"]), + ("language", language("python"), &["gap:test:exposed-python"]), + ( + "language rust", + language("rust"), + &["gap:test:ready", "finding:test:unready"], + ), + ( + "file exact", + file("./src/checkout.rs"), + &["gap:test:ready", "finding:test:unready"], + ), + ( + "file bare", + file("src/checkout.rs"), + &["gap:test:ready", "finding:test:unready"], + ), + ( + "file basename", + file("checkout.rs"), + &["gap:test:ready", "finding:test:unready"], + ), + ( + "file prefix", + file("src/"), + &[ + "gap:test:ready", + "gap:test:exposed-python", + "finding:test:unready", + "gap:test:unlocalized", + ], + ), + ( + "ready true", + ready(true), + &[ + "gap:test:ready", + "gap:test:exposed-python", + "gap:test:unlocalized", + ], + ), + ("ready false", ready(false), &["finding:test:unready"]), + ]; + for (name, filter, expected) in cases { + let document = filtered(filter)?; + let mut ids = gap_ids(&document)?; + ids.sort(); + let mut expected = expected.to_vec(); + expected.sort(); + if ids != expected { + return Err(format!("{name} narrowed to {ids:?}, expected {expected:?}")); + } + if document.pointer("/filtered").and_then(Value::as_u64) != Some(expected.len() as u64) + { + return Err(format!("{name} lost its filtered count: {document}")); + } + if document.pointer("/selected").and_then(Value::as_u64) != Some(4) { + return Err(format!( + "{name} must not rewrite the stored-selection count: {document}" + )); + } + } + + // `selected` stays the budget count while `filtered` counts the + // narrowed set, and the request is echoed for audit. + let document = filtered(&file("src/checkout.rs"))?; + if document.pointer("/filters/file").and_then(Value::as_str) != Some("src/checkout.rs") + || document.pointer("/filters/class") != Some(&Value::Null) + || document.pointer("/filters/language") != Some(&Value::Null) + || document.pointer("/filters/repair_ready") != Some(&Value::Null) + { + return Err(format!("narrowed list must echo its filters: {document}")); + } + + // Dimensions combine conjunctively. + let combined = filtered(&GapListFilter { + file: Some("src/checkout.rs".to_string()), + repair_ready: Some(false), + ..Default::default() + })?; + if gap_ids(&combined)? != vec!["finding:test:unready".to_string()] { + return Err(format!("combined filters must conjoin: {combined}")); + } + let combined = filtered(&GapListFilter { + class: Some("weakly_exposed".to_string()), + repair_ready: Some(true), + ..Default::default() + })?; + if gap_ids(&combined)? != vec!["gap:test:ready".to_string()] { + return Err(format!("combined filters must conjoin: {combined}")); + } + + // An unknown value narrows to an empty disclosed page, not an error. + let empty = filtered(&class("bogus"))?; + if !gap_ids(&empty)?.is_empty() + || empty.pointer("/filtered").and_then(Value::as_u64) != Some(0) + || empty.pointer("/page/returned").and_then(Value::as_u64) != Some(0) + || empty.pointer("/page/has_more").and_then(Value::as_bool) != Some(false) + || empty.pointer("/selected").and_then(Value::as_u64) != Some(4) + { + return Err(format!( + "unknown filter value must be an empty disclosed page: {empty}" + )); + } + + // Filter-then-page: the window walks the narrowed set, and the bound + // continuation resumes narrowed. + let first = session + .list_gaps( + None, + GapListWindow { + offset: 0, + limit: Some(1), + }, + &file("src/checkout.rs"), + ) + .map_err(|failure| failure.detail)?; + if first.pointer("/page/returned").and_then(Value::as_u64) != Some(1) + || first.pointer("/page/has_more").and_then(Value::as_bool) != Some(true) + || first.pointer("/page/next_offset").and_then(Value::as_u64) != Some(1) + || first.pointer("/filtered").and_then(Value::as_u64) != Some(2) + { + return Err(format!( + "first narrowed page must disclose its window: {first}" + )); + } + if first + .pointer("/continuation/next_page/arguments/file") + .and_then(Value::as_str) + != Some("src/checkout.rs") + || first + .pointer("/continuation/next_page/arguments/offset") + .and_then(Value::as_u64) + != Some(1) + || first + .pointer("/continuation/next_page/arguments/limit") + .and_then(Value::as_u64) + != Some(1) + { + return Err(format!( + "the bound continuation must pin the narrowed walk: {first}" + )); + } + let second = session + .list_gaps( + None, + GapListWindow { + offset: 1, + limit: Some(1), + }, + &file("src/checkout.rs"), + ) + .map_err(|failure| failure.detail)?; + if second.pointer("/page/has_more").and_then(Value::as_bool) != Some(false) { + return Err(format!("second narrowed page must terminate: {second}")); + } + let mut walked = gap_ids(&first)?; + walked.extend(gap_ids(&second)?); + walked.sort(); + if walked + != vec![ + "finding:test:unready".to_string(), + "gap:test:ready".to_string(), + ] + { + return Err(format!( + "paged walk must cover the narrowed set once: {walked:?}" + )); + } + Ok(()) + } + + /// #7464: the file matcher accepts exact, prefix, and trailing-segment + /// spellings across the `./` boundary, and refuses partial-segment + /// prefixes and empty filters. + #[test] + fn gap_file_filter_matching_is_segment_bounded() { + for filter in [ + "./src/checkout.rs", + "src/checkout.rs", + "checkout.rs", + "./src", + "src", + "src/", + ] { + assert!( + gap_file_matches("./src/checkout.rs", filter), + "{filter} must match ./src/checkout.rs" + ); + } + for filter in [ + "src/check", + "src/checkout", + "checkout.r", + "src/other.rs", + "src/checkout.rs/", + "", + ] { + assert!( + !gap_file_matches("./src/checkout.rs", filter), + "{filter} must not match ./src/checkout.rs" + ); + } + assert!(!gap_file_matches("./src/checkout.rs", "./src/checkout.rs/")); + } + /// #7462: the single-item read is already the narrow MCP route. An item /// that does not fit must not tell the caller to call `ripr_get_gap` again. /// The routed exercise lives in `server_tests.rs` @@ -1539,7 +2087,7 @@ mod tests { -> Result<(), String> { let session = session_with_findings(700)?; let document = session - .list_gaps(None, GapListWindow::default()) + .list_gaps(None, GapListWindow::default(), &GapListFilter::default()) .map_err(|failure| failure.detail)?; // The page itself must fit the wire envelope end to end, with the @@ -1640,6 +2188,7 @@ mod tests { offset, limit: None, }, + &GapListFilter::default(), ) .map_err(|failure| failure.detail)?; let ids = document @@ -1689,6 +2238,7 @@ mod tests { offset: 0, limit: Some(1), }, + &GapListFilter::default(), ) .map_err(|failure| failure.detail)?; if limited.pointer("/page/limit").and_then(Value::as_u64) != Some(1) @@ -1710,6 +2260,7 @@ mod tests { offset: requested_offset, limit: None, }, + &GapListFilter::default(), ) .map_err(|failure| failure.detail)?; if beyond @@ -1736,7 +2287,7 @@ mod tests { fn fitting_listing_ships_whole_with_a_closed_page_window() -> Result<(), String> { let session = session_with_findings(3)?; let document = session - .list_gaps(None, GapListWindow::default()) + .list_gaps(None, GapListWindow::default(), &GapListFilter::default()) .map_err(|failure| failure.detail)?; if document.pointer("/selected").and_then(Value::as_u64) != Some(3) || document diff --git a/crates/ripr/tests/fixtures/mcp-gap-list-v1.schema.json b/crates/ripr/tests/fixtures/mcp-gap-list-v1.schema.json new file mode 100644 index 00000000000..21f8ffdd47d --- /dev/null +++ b/crates/ripr/tests/fixtures/mcp-gap-list-v1.schema.json @@ -0,0 +1,171 @@ +{ + "type": "object", + "properties": { + "schema_version": { + "type": "string", + "const": "ripr-mcp-gap-list-v1" + }, + "snapshot_id": { + "type": "string" + }, + "requested_snapshot_id": { + "type": [ + "string", + "null" + ] + }, + "snapshot_profile_budget_identity": { + "type": "string" + }, + "selection_basis_version": { + "type": "string" + }, + "budget": { + "type": "object", + "properties": { + "max_items_per_workspace_response": { + "type": "integer", + "minimum": 1 + }, + "max_items_per_document": { + "type": "integer", + "minimum": 1 + }, + "max_serialized_bytes": { + "type": "integer", + "minimum": 1 + }, + "max_inline_detail_bytes": { + "type": "integer", + "minimum": 1 + } + }, + "required": [ + "max_items_per_workspace_response", + "max_items_per_document", + "max_serialized_bytes", + "max_inline_detail_bytes" + ], + "additionalProperties": false + }, + "total": { + "type": "integer", + "minimum": 0 + }, + "eligible": { + "type": "integer", + "minimum": 0 + }, + "selected": { + "type": "integer", + "minimum": 0 + }, + "omitted": { + "type": "integer", + "minimum": 0 + }, + "selected_bytes": { + "type": "integer", + "minimum": 0 + }, + "complete_bytes": { + "type": "integer", + "minimum": 0 + }, + "overflowed": { + "type": "boolean" + }, + "overflow_reasons": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "document_item_limit", + "workspace_item_limit", + "serialized_byte_limit", + "inline_detail_limit" + ] + } + }, + "items": { + "type": "array" + }, + "page": { + "type": "object", + "properties": { + "offset": { + "type": "integer", + "minimum": 0 + }, + "limit": { + "type": [ + "integer", + "null" + ], + "minimum": 1, + "description": "The caller-set page cap; null when the page byte-filled." + }, + "returned": { + "type": "integer", + "minimum": 0 + }, + "has_more": { + "type": "boolean" + }, + "next_offset": { + "type": [ + "integer", + "null" + ], + "minimum": 0 + } + }, + "required": [ + "offset", + "limit", + "returned", + "has_more", + "next_offset" + ], + "additionalProperties": false + }, + "omitted_items": { + "type": "array" + }, + "continuation": { + "type": "object" + }, + "claim_boundary": { + "type": "string" + }, + "limitations": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "schema_version", + "snapshot_id", + "requested_snapshot_id", + "snapshot_profile_budget_identity", + "selection_basis_version", + "budget", + "total", + "eligible", + "selected", + "omitted", + "selected_bytes", + "complete_bytes", + "overflowed", + "overflow_reasons", + "items", + "page", + "omitted_items", + "continuation", + "claim_boundary", + "limitations" + ], + "additionalProperties": false +} diff --git a/crates/ripr/tests/mcp_stdio.rs b/crates/ripr/tests/mcp_stdio.rs index 70a2fdfb53a..5225ae65ee2 100644 --- a/crates/ripr/tests/mcp_stdio.rs +++ b/crates/ripr/tests/mcp_stdio.rs @@ -334,6 +334,27 @@ fn optional_tool_arguments_reject_null_and_recover_over_stdio() -> Result<(), St ), ("ripr_list_gaps", "offset", json!({}), json!(0), "integer"), ("ripr_list_gaps", "limit", json!({}), json!(1), "integer"), + ( + "ripr_list_gaps", + "file", + json!({}), + json!("src/input-control.rs"), + "string", + ), + ( + "ripr_list_gaps", + "class", + json!({}), + json!("weakly_exposed"), + "string", + ), + ( + "ripr_list_gaps", + "language", + json!({}), + json!("rust"), + "string", + ), ( "ripr_get_gap", "snapshot_id", @@ -1718,6 +1739,312 @@ fn install_b4_repair_ready_fixture() -> Result { Ok(root) } +/// Real committed multi-item input for RIPR-SPEC-0211 / #7464. The two +/// pricing boundaries have strong test sites; the uncovered Rust predicates +/// and (when compiled) Python predicate provide distinct excluded subjects. +fn install_gap_filter_fixture() -> Result { + let root = install_b4_repair_ready_fixture()?; + std::fs::write( + root.join("src/lib.rs"), + "pub mod pricing;\npub mod uncovered;\n", + ) + .map_err(|error| error.to_string())?; + std::fs::write(root.join(".gitignore"), ".ripr/\ntarget/\n") + .map_err(|error| error.to_string())?; + let pricing = "pub fn discount(amount: i32, threshold: i32) -> i32 {\n if amount >= threshold { amount - 10 } else { amount }\n}\npub fn fee(amount: i32, threshold: i32) -> i32 {\n if amount >= threshold { amount + 5 } else { amount }\n}\n"; + let uncovered = + "pub fn accepts(amount: i32, threshold: i32) -> bool {\n amount >= threshold\n}\n"; + std::fs::write(root.join("src/pricing.rs"), pricing).map_err(|error| error.to_string())?; + std::fs::write(root.join("src/uncovered.rs"), uncovered).map_err(|error| error.to_string())?; + std::fs::write(root.join("tests/pricing.rs"), "use mcp_journey_fixture::pricing::{discount, fee};\n#[test]\nfn discount_boundary() {\n assert_eq!(discount(100, 100), 90);\n}\n#[test]\nfn fee_boundary() {\n assert_eq!(fee(100, 100), 105);\n}\n").map_err(|error| error.to_string())?; + let languages = if cfg!(feature = "lang-python") { + std::fs::write( + root.join("pyproject.toml"), + "[project]\nname = \"mcp-filter-fixture\"\nversion = \"0.0.0\"\n", + ) + .map_err(|error| error.to_string())?; + std::fs::write(root.join("src/cart.py"), "def accepts(amount, threshold):\n if amount > threshold:\n return amount - 1\n return amount\n").map_err(|error| error.to_string())?; + "[languages]\nenabled = [\"rust\", \"python\"]\n" + } else { + "[languages]\nenabled = [\"rust\"]\n" + }; + std::fs::write(root.join("ripr.toml"), languages).map_err(|error| error.to_string())?; + commit_fixture(&root, "filter baseline")?; + fixture_git_ok(&root, &["update-ref", "refs/heads/main", "HEAD"])?; + std::fs::write(root.join("src/pricing.rs"), pricing.replace(">=", ">")) + .map_err(|error| error.to_string())?; + std::fs::write(root.join("src/uncovered.rs"), uncovered.replace(">=", ">")) + .map_err(|error| error.to_string())?; + if cfg!(feature = "lang-python") { + std::fs::write(root.join("src/cart.py"), "def accepts(amount, threshold):\n if amount >= threshold:\n return amount - 1\n return amount\n").map_err(|error| error.to_string())?; + } + commit_fixture(&root, "narrow Rust and widen Python boundaries")?; + Ok(root) +} + +fn check_filtered_gap_page( + document: &Value, + expected_ids: &[&str], + selected: usize, + filtered: usize, + snapshot_id: &str, +) -> Result<(), String> { + let items = document["items"].as_array().ok_or("list omitted items")?; + let ids = items + .iter() + .map(|item| item["canonical_id"].as_str().ok_or("item omitted ID")) + .collect::, _>>()?; + if ids != expected_ids + || document["selected"] != json!(selected) + || document["filtered"] != json!(filtered) + || document["page"]["returned"] != json!(expected_ids.len()) + || document["snapshot_id"] != snapshot_id + || document["schema_version"] != "ripr-mcp-gap-list-v2" + { + return Err(format!( + "filtered transport page differs from exact IDs/counts: expected {expected_ids:?}, selected={selected}, filtered={filtered}: {document}" + )); + } + Ok(()) +} + +/// A successful raw-stdio discriminator, including actual continuation replay. +/// Dropping only the forwarded filter after validation must return excluded +/// subjects and fail these literal ID/count oracles. No synthetic snapshot is +/// injected and no WorkspaceSession method is called by this test. +#[test] +fn refreshed_gap_filters_narrow_real_stdio_and_replay_bound_continuation() -> Result<(), String> { + const DISCOUNT: &str = + "gap:rust:src/pricing.rs:discount:predicate_boundary:predicate:amount==threshold"; + const FEE: &str = "gap:rust:src/pricing.rs:fee:predicate_boundary:predicate:amount==threshold"; + const UNCOVERED: &str = + "gap:rust:src/uncovered.rs:accepts:predicate_boundary:predicate:amount==threshold"; + const RETURN: &str = + "gap:rust:src/uncovered.rs:accepts:return_value:return_value:amount>threshold"; + const PYTHON: &str = + "gap:python:src/cart.py:accepts:predicate_boundary:predicate:amount>=threshold"; + let timeout = Duration::from_mins(1); + let root = install_gap_filter_fixture()?; + let _guard = FixtureGuard { root: root.clone() }; + let (binary, digest) = Observation::executable_custody(Path::new(env!("CARGO_BIN_EXE_ripr")))?; + let fixture_tree = + common::fixture_git::fixture_git_output(&root, &["rev-parse", "HEAD^{tree}"])?; + eprintln!( + "filter control fixture_tree={} binary={} sha256={digest}", + fixture_tree.trim(), + binary.display() + ); + let mut session = SequentialStdio::spawn(&root)?; + let discovery = session.call("discover-filters", "server/discover", json!({}), timeout)?; + if discovery.get("result").is_none() { + return Err(format!("discovery failed: {discovery}")); + } + let refresh = session.call_tool( + "refresh-filters", + "ripr_refresh", + json!({}), + Duration::from_mins(3), + )?; + let refresh = structured_tool_success(&refresh, "filter refresh")?; + if refresh["attempt"]["state"] != "completed" + || refresh["snapshot"]["outcome_kind"] != "complete_with_findings" + { + return Err(format!( + "fixture must complete analysis before filter assertions: {refresh}" + )); + } + let all = session.call_tool("all-gaps", "ripr_list_gaps", json!({}), timeout)?; + let all = structured_tool_success(&all, "unfiltered list")?; + let snapshot_id = all["snapshot_id"] + .as_str() + .ok_or("list omitted snapshot ID")?; + let mut all_ids = vec![DISCOUNT, FEE, UNCOVERED, RETURN]; + let mut unready = vec![UNCOVERED, RETURN]; + if cfg!(feature = "lang-python") { + all_ids.insert(0, PYTHON); + unready.insert(0, PYTHON); + } + let selected = all_ids.len(); + check_filtered_gap_page(&all, &all_ids, selected, selected, snapshot_id)?; + for item in all["items"].as_array().ok_or("list omitted items")? { + let id = item["canonical_id"].as_str().ok_or("item omitted ID")?; + let ready = [DISCOUNT, FEE].contains(&id); + if item["repair_packet_ready"] != ready + || item["repair_ineligibility"] + != if ready { + Value::Null + } else { + json!("fix_site_not_established") + } + || item["class"] != if ready { "exposed" } else { "no_static_path" } + { + return Err(format!( + "fixture lost distinct class/readiness subjects: {item}" + )); + } + let gap = session.call_tool( + "readiness", + "ripr_get_gap", + json!({"canonical_id": id, "snapshot_id": snapshot_id}), + timeout, + )?; + let gap = structured_tool_success(&gap, "get gap readiness")?; + if gap.pointer("/item/readiness/repair_packet_ready") != Some(&json!(ready)) { + return Err(format!("summary and full-gap readiness disagree: {gap}")); + } + } + + // Frozen pre-feature v1 success schema, from a7ed66f6e. Its closed top + // level rejects the two added fields even when they are called additive. + let v1: Value = serde_json::from_str(include_str!("fixtures/mcp-gap-list-v1.schema.json")) + .map_err(|error| error.to_string())?; + let properties = v1["properties"] + .as_object() + .ok_or("v1 fixture omitted properties")?; + let required = v1["required"] + .as_array() + .ok_or("v1 fixture omitted required")?; + let accepts_v1_shape = |document: &Value| { + document.as_object().is_some_and(|object| { + object.keys().all(|key| properties.contains_key(key)) + && required + .iter() + .all(|key| key.as_str().is_some_and(|key| object.contains_key(key))) + }) + }; + let mut legacy = all.clone(); + let legacy_object = legacy.as_object_mut().ok_or("list must be an object")?; + legacy_object.remove("filtered"); + legacy_object.remove("filters"); + legacy_object.insert("schema_version".into(), json!("ripr-mcp-gap-list-v1")); + if v1["additionalProperties"] != false || !accepts_v1_shape(&legacy) || accepts_v1_shape(&all) { + return Err( + "strict v1 top-level closure must accept legacy keys and reject the extended envelope" + .into(), + ); + } + + let mut cases = vec![ + (json!({"file": "./src/pricing.rs"}), vec![DISCOUNT, FEE]), + (json!({"file": "pricing.rs"}), vec![DISCOUNT, FEE]), + (json!({"file": "src/uncovered.rs"}), vec![UNCOVERED, RETURN]), + (json!({"class": "exposed"}), vec![DISCOUNT, FEE]), + (json!({"class": "no_static_path"}), unready.clone()), + ( + json!({"language": "rust"}), + vec![DISCOUNT, FEE, UNCOVERED, RETURN], + ), + (json!({"repair_ready": true}), vec![DISCOUNT, FEE]), + (json!({"repair_ready": false}), unready), + ( + json!({"file": "src/pricing.rs", "class": "exposed", "language": "rust", "repair_ready": true}), + vec![DISCOUNT, FEE], + ), + ( + json!({"file": "src/pricing.rs", "class": "no_static_path"}), + vec![], + ), + (json!({"class": "unknown-class"}), vec![]), + (json!({"language": "unknown-language"}), vec![]), + (json!({"file": "missing.rs"}), vec![]), + ]; + if cfg!(feature = "lang-python") { + cases.push((json!({"language": "python"}), vec![PYTHON])); + } + for (arguments, expected) in cases { + let reply = session.call_tool("filtered", "ripr_list_gaps", arguments.clone(), timeout)?; + let document = structured_tool_success(&reply, "filtered list")?; + check_filtered_gap_page(&document, &expected, selected, expected.len(), snapshot_id)?; + for field in ["file", "class", "language", "repair_ready"] { + if document["filters"][field] != arguments[field] { + return Err(format!("filter echo lost {field}: {document}")); + } + } + if document["page"]["has_more"] != false || document["page"]["next_offset"] != Value::Null { + return Err(format!( + "complete filtered page must close its window: {document}" + )); + } + } + let first_args = json!({"file":"src/pricing.rs", "class":"exposed", "language":"rust", "repair_ready":true, "limit":1, "snapshot_id":snapshot_id}); + let first = session.call_tool("filtered-first", "ripr_list_gaps", first_args, timeout)?; + let first = structured_tool_success(&first, "first filtered page")?; + check_filtered_gap_page(&first, &[DISCOUNT], selected, 2, snapshot_id)?; + let next = first + .pointer("/continuation/next_page") + .ok_or("first page omitted bound continuation")?; + let expected_args = json!({"snapshot_id":snapshot_id, "offset":1, "limit":1, "file":"src/pricing.rs", "class":"exposed", "language":"rust", "repair_ready":true}); + if first["page"] + != json!({"offset":0, "limit":1, "returned":1, "has_more":true, "next_offset":1}) + || next["tool"] != "ripr_list_gaps" + || next["arguments"] != expected_args + { + return Err(format!( + "filtered continuation lost its exact window/binding: {first}" + )); + } + let next_tool = next["tool"].as_str().ok_or("continuation omitted tool")?; + let replay = session.call_tool( + "filtered-replay", + next_tool, + next["arguments"].clone(), + timeout, + )?; + let replay = structured_tool_success(&replay, "replayed filtered page")?; + check_filtered_gap_page(&replay, &[FEE], selected, 2, snapshot_id)?; + if replay["page"] + != json!({"offset":1, "limit":1, "returned":1, "has_more":false, "next_offset":null}) + || replay.pointer("/continuation/next_page").is_some() + { + return Err(format!( + "filtered replay must finish exactly once: {replay}" + )); + } + let status = session.call_tool("filter-status", "ripr_workspace_status", json!({}), timeout)?; + let status = structured_tool_success(&status, "status after filters")?; + if status.pointer("/session/last_completed_snapshot/snapshot_id") != Some(&json!(snapshot_id)) { + return Err(format!( + "filter reads changed the completed snapshot: {status}" + )); + } + // A different committed input replaces the snapshot. Replay the actual + // old continuation unchanged; no fabricated stale identity is supplied. + std::fs::write( + root.join("src/uncovered.rs"), + "pub fn accepts(amount: i32, threshold: i32) -> bool {\n amount < threshold\n}\n", + ) + .map_err(|error| error.to_string())?; + commit_fixture(&root, "replace uncovered predicate")?; + let replaced = session.call_tool( + "replace-refresh", + "ripr_refresh", + json!({}), + Duration::from_mins(3), + )?; + let replaced = structured_tool_success(&replaced, "replacement refresh")?; + if replaced["attempt"]["state"] != "completed" + || replaced["snapshot"]["snapshot_id"] == snapshot_id + { + return Err(format!( + "changed committed input must replace the snapshot: {replaced}" + )); + } + let stale = session.call_tool( + "stale-replay", + next_tool, + next["arguments"].clone(), + timeout, + )?; + if stale.pointer("/result/isError") != Some(&json!(true)) + || stale.pointer("/result/structuredContent/failure/code") != Some(&json!("stale_snapshot")) + { + return Err(format!( + "old generated continuation must fail stale: {stale}" + )); + } + Ok(()) +} + fn structured_tool_success(reply: &Value, context: &str) -> Result { let result = reply .get("result") diff --git a/docs/OUTPUT_SCHEMA.md b/docs/OUTPUT_SCHEMA.md index e18c8028606..5a64947c87a 100644 --- a/docs/OUTPUT_SCHEMA.md +++ b/docs/OUTPUT_SCHEMA.md @@ -65,6 +65,7 @@ map is: | badge JSON | `schema_version` | `0.8` | | `ripr cache status --json` | `schema_version` | `0.2` | | `ripr mcp` status tool and resource | `schema_version` | `ripr-mcp-workspace-status-v1` (see [MCP workspace status server](interop/mcp.md)) | +| `ripr_list_gaps` success and refusal | `schema_version` | `ripr-mcp-gap-list-v2`; strict v1 readers migrate via `tools/list` (see [MCP gap filters](interop/mcp.md)) | | `ripr swarm queue --json` | `schema_version` | `0.2` | | `ripr help --json` | `schema_version` | `2` | | `ripr agent card --json` and the `RepairCardV1` DTO (RIPR-SPEC-0192, RIPR-SPEC-0194; `ripr agent card` is the default CLI handoff, #4667) | `schema_version` | `repair_card.v1` | diff --git a/docs/interop/mcp.md b/docs/interop/mcp.md index 615940c2a4a..9ef39d9e0d2 100644 --- a/docs/interop/mcp.md +++ b/docs/interop/mcp.md @@ -95,7 +95,7 @@ runs no tests or verification and grants no execution or edit authority. | --- | --- | | Tool (no arguments) | `ripr_workspace_status` | | Tool (no arguments) | `ripr_refresh` | -| Tool (`snapshot_id?`, `offset?`, `limit?`) | `ripr_list_gaps` | +| Tool (`snapshot_id?`, `offset?`, `limit?`, `file?`, `class?`, `language?`, `repair_ready?`) | `ripr_list_gaps` | | Tool (`canonical_id`, `snapshot_id?`) | `ripr_get_gap` | | Tool (`canonical_id`, `snapshot_id?`) | `ripr_prepare_repair` | | Tool (`attempt_id`) | `ripr_get_repair_attempt` | @@ -164,31 +164,55 @@ zero-config language auto-enable, and a present-but-unreadable or unparseable config fails the attempt closed with `config_invalid`. Provider configuration stays unloaded. +Gap-list responses use `ripr-mcp-gap-list-v2`, including typed refusals. +The prior v1 success schema forbids unknown top-level properties, so the new +`filtered` and `filters` fields require this version change. Strict v1 readers +must rediscover `tools/list`, accept v2 explicitly and validate against the +advertised `outputSchema`; callers may still omit all filter arguments. +Other MCP document versions are unchanged. + `ripr_list_gaps` returns the snapshot's deterministic bounded working set: -`total` / `eligible` / `selected` / `omitted` counts, selected and complete +`total` / `eligible` / `selected` / `filtered` counts, selected and complete serialized bytes, every omitted identity with its reason, the -snapshot/profile/budget identity and selection basis, and one small summary -per selected item. Selection is the shared CLI/LSP diagnostic-budget -authority over the snapshot's canonical items; eligibility is the producer's -candidate-actionability predicate captured at projection time, so -non-actionable items appear as disclosed profile-filtered omissions. The -adapter never re-ranks, +snapshot/profile/budget identity and selection basis, the echoed `filters`, +and one small summary per selected item. Each summary carries +`canonical_id`, exposure `class`, `language`, `file`, `line`, plus the +commit-time repair-readiness projection (`repair_packet_ready` with its typed +`repair_ineligibility` reason, `null` when ready) — the same +`repair_packet_ready` fact the item's `ripr_get_gap` readiness block reports, +so actionable items sort without one evidence call per candidate. Selection +is the shared CLI/LSP diagnostic-budget authority over the snapshot's +canonical items; eligibility is the producer's candidate-actionability +predicate captured at projection time, so non-actionable items appear as +disclosed profile-filtered omissions. The adapter never re-ranks, never truncates silently, and infers no business risk. Overflow is disclosed with reasons and the continuation route (`ripr_get_gap`). Pass `snapshot_id` to bind the read to a specific snapshot: a mismatched identity fails closed with `stale_snapshot` and the current identity. +Optional `file`, `class`, `language`, and `repair_ready` narrow the stored +selection over already-projected commit-time facts before paging +(conjunctive): `file` matches exact, prefix, or trailing-segment paths after +ignoring one leading `./` on both sides, `class` takes an exposure-class wire +token (for example `exposed`), `language` takes a language wire string (for +example `rust`), and `repair_ready: true` (or `false`) selects the +commit-time readiness projection. `selected` stays the full stored-selection +count while `filtered` counts the narrowed set the page walks; an unknown +filter value is an empty disclosed page, not an error. Empty filter strings +and non-boolean `repair_ready` values are Invalid Params. + Paging (#6021): `offset` (default 0) and `limit` (minimum 1) page over the -selected items in snapshot order, disclosed through the `page` window +narrowed items in snapshot order, disclosed through the `page` window (`offset`, `limit` when caller-set, `returned`, `has_more`, `next_offset`). Optional tool fields must be omitted to use their defaults: explicit `null` -is invalid for `snapshot_id`, `offset`, and `limit` (#7314). The server +is invalid for `snapshot_id`, `offset`, `limit`, `file`, `class`, +`language`, and `repair_ready` (#7314). The server returns `-32602` Invalid Params naming the field with the same request ID; correct the argument or omit it and retry on the same connection. When the whole selection cannot fit one wire response, the default call returns the first wire-fitting page and `continuation.next_page` names the `ripr_list_gaps` call that resumes the walk — pinned to the snapshot -identity, so a refresh between pages fails closed with `stale_snapshot` +identity and the caller filters, so a refresh between pages fails closed with `stale_snapshot` instead of silently mixing snapshots; walking `next_offset` covers the selection exactly once. Pages are sized so the complete structured result (`structuredContent`, per the tool's advertised `outputSchema`) measures diff --git a/docs/specs/RIPR-SPEC-0211-mcp-workspace-session-evidence.md b/docs/specs/RIPR-SPEC-0211-mcp-workspace-session-evidence.md index 0417555226c..dc7df62f326 100644 --- a/docs/specs/RIPR-SPEC-0211-mcp-workspace-session-evidence.md +++ b/docs/specs/RIPR-SPEC-0211-mcp-workspace-session-evidence.md @@ -134,6 +134,24 @@ official SDK transport: adapter never re-runs ranking, never truncates silently, and infers no business risk. Overflow is disclosed with reasons and the `ripr_get_gap` continuation route. +- Optional `file`, `class`, `language`, and `repair_ready` filters narrow + the stored selection by conjunction before paging; they never re-run + analysis or widen the shared budget. File matching removes a leading `./` + and accepts exact paths, segment-bounded prefixes, and trailing segments. + Class/language are exact wire tokens; unknown values produce an empty page. + `selected` remains the stored-selection count; `filtered` is the narrowed + count. `filters` echoes all four dimensions, with null for omitted values. + Summaries carry `repair_packet_ready` and `repair_ineligibility` (null when + ready; otherwise the typed first failing gate), matching `ripr_get_gap`. + `continuation.next_page.arguments` pins the snapshot, filters, and explicit + limit; replay cannot cross a completed refresh that replaced the snapshot. +- Gap-list success and refusal documents use `ripr-mcp-gap-list-v2`. + The former v1 success schema closed its top level with + `additionalProperties: false`, so adding `filtered` and `filters` cannot + retain strict v1 compatibility. Clients must rediscover `tools/list`, accept + v2 explicitly and use the advertised output schema. The input arguments + remain compatible for callers omitting filters; strict v1 output readers + require migration. Other MCP document versions are unchanged. - The tool envelope carries the document once at full fidelity (#6021): `content[0].text` is the compact JSON serialization of the structured document (no pretty-print inflation), and `structuredContent` repeats @@ -144,16 +162,17 @@ official SDK transport: sent over the cap: when even the compact-text envelope cannot fit, the call fails closed with `result_too_large` naming both sizes. - `ripr_list_gaps` accepts `offset` (default 0) and `limit` (minimum 1) - over the selected items in snapshot order. When the whole selection + over the narrowed (filtered) items in snapshot order. When the narrowed set would exceed the wire-calibrated tool-document ceiling (half the response bound, the worst-case escaping budget), the default call returns the first wire-fitting page and discloses the window through `page` (`offset` echoing the request, `limit` when the caller set it, `returned`, `has_more`, `next_offset`); walking `next_offset` covers the - selection exactly once. Pages are sized so the complete double-carry + narrowed set exactly once. Pages are sized so the complete double-carry envelope measures under the response bound: a paged success always carries `structuredContent`, as the tool's advertised `outputSchema` - requires. The generated `next_page` route pins the snapshot identity, so + requires. The generated `next_page` route pins the snapshot identity, + filters, and explicit limit, so a refresh between pages fails closed with `stale_snapshot` instead of mixing snapshots. Only a listing that cannot fit even one page — for example an omission disclosure alone over the ceiling — fails closed @@ -310,6 +329,19 @@ official SDK transport: ## Test Mapping +- `crates/ripr/tests/mcp_stdio.rs::refreshed_gap_filters_narrow_real_stdio_and_replay_bound_continuation` + — actual committed multi-item analysis over raw stdio: literal IDs, counts, + class/language/readiness exclusion, conjunction, unknown-value empty sets, + filtered one-item continuation replay, unchanged snapshot after reads, and + stale replay after replacement. The frozen pre-feature closed v1 success + schema rejects the extended envelope, which carries v2. A dropped-forwarding + experiment must fail this oracle after argument validation. +- `crates/ripr/src/mcp/workspace.rs::tests::gap_list_summaries_project_readiness_matching_get_gap` + + `gap_list_filters_narrow_each_dimension_then_combine_before_paging` + — direct stored-fact narrowing/readiness and continuation controls. +- `crates/ripr/src/mcp/server_tests.rs::list_gaps_accepts_filters_at_the_dispatch_edge` + — argument admission before refresh; this is not successful narrowing proof. + - `crates/ripr/src/mcp/workspace.rs::tests` — session lifecycle, typed failures, identity portability, boundedness, last-known-good retention; `session_profile_resolves_the_workspace_configuration` pins the #6825 @@ -356,6 +388,8 @@ official SDK transport: ## Metrics - `mcp_tools` (4) and `mcp_resource_templates` (2) on the slice surface +- refreshed filter control subjects: five with Python, four in Rust-only builds; + every positive narrowing asserts a nonempty fixture and literal IDs - typed pre-refresh failure controls on the wire (target: 3 — list, get, snapshot resource) - zero committed snapshots for `unsupported_input` / `analysis_failed` diff --git a/policy/non-rust-allowlist.toml b/policy/non-rust-allowlist.toml index c5b60c452b0..b5ec92c98cc 100644 --- a/policy/non-rust-allowlist.toml +++ b/policy/non-rust-allowlist.toml @@ -752,6 +752,15 @@ covered_by = ["cargo test -p ripr --test causal_delta_fixture", "cargo xtask che # Portable consumer (Python stdlib packet transport) # --------------------------------------------------------------------------- +[[allow]] +glob = "crates/ripr/tests/fixtures/mcp-gap-list-v1.schema.json" +kind = "json_schema" +owner = "mcp" +surface = "fixtures" +classification = "fixture" +reason = "Frozen pre-filter gap-list v1 schema for strict-reader transport compatibility control." +covered_by = ["cargo test -p ripr --test mcp_stdio", "cargo xtask check-file-policy"] + [[allow]] glob = "tools/python/portable-ripr-consumer/**/*.py" kind = "portable_native_consumer"