Repository navigation
impl(042): increment 6 part 2, the explanation handler - #430
Conversation
AI review (findings)Looking at the PR diff, I'll review the changes for the explanation handler implementation across
The
The scope-check logic is correct: bundle cases require both
Test bug — // handlers.rs, inside explain_goldens()
let form = |v: &Value| {
let keys: Vec<&str> = v.as_object().unwrap().keys().map(String::as_str).collect();
matches!(
keys.as_slice(),
["bundle"] | ["record"] | ["plan", "record"] // ← order-sensitive
)
};
{"head": "c0b9051a8e8c0b50426a4eee4c4119eea7c60e60", "verdict": "findings", "findings": [{"path": "integrations/rustev-serve/tests/handlers.rs", "line": null, "summary": "The `form` closure in `every_explain_golden_through_both_transports` uses `matches!(keys.as_slice(), … | [\"plan\", \"record\"])`, which is order-sensitive; a conformance case with keys in `[\"record\", \"plan\"]` order is misclassified as invalid form and the test asserts `InvalidDocument` when the handler would return a successful explanation."}]}Subject: 682bde9...c0b9051, diff digest 93b8e341ba84185d43f0741e452e35e17916b13077900e440f3a05d8a63ecc9f, 1 call(s). An AI comment is not an approval. |
Spec 042 3.8.3: POST /v1/explain and gRPC Explain run the library's explanation through rustev-surface on the blocking pool, with the caller's scope checked, references read under the configured roots, the listener's redaction policy, and spec 040 refusals as invalid_document. The request documents now parse embedded evidence, which the untagged enums never could.
c0b9051 to
d587104
Compare
AI review (no-findings)Reviewing the diff carefully across all changed files.
(true, Some(given), Some(now_ms)) if *given == scope => Some(now_ms),
(true, Some(_), Some(_)) => DecisionNotFound,
(false, None, None) => None,
_ => InvalidRequest,This correctly enforces spec 040 3.16.2: scope+nowMs required exactly when a bundle side is present, scope mismatch is
No concrete defects found in any changed file. {"head": "d5871049a1ccfc9aa1070916b9ff54d3cb3286cd", "verdict": "no-findings", "findings": []}Subject: 682bde9...d587104, diff digest 8e8641439301632f539eb26a0ef8de3202bea4fcae8f23cbec606637db397699, 1 call(s). An AI comment is not an approval. |
Spec 042 increment 6 part 2: the explanation handler (3.8.3, as amended by #404; documents from #411).
POST /v1/explainand gRPCExplainrun on the blocking pool and honor the deadline header.options.scopemust equal the scope the host resolves for the caller's principal; otherwise the answer isdecision_not_foundand nothing is resolved or explained.scopeornow_msgiven without a bundle side, or missing with one, isinvalid_request...reference or a missing file is refused.invalid_document, with spec 040's code indetail.explainamong its available endpoints.Contract fix: the request documents merged in #411 could not parse evidence embedded as a document (only references parsed).
crates/rustev-contractnow parsesevidenceanddiffqueries in both forms; the accepted shapes and the committed JSON Schema are unchanged. A contract test covers embedded documents.Tests: every explain golden that does not pass the library its own resolver runs through HTTP/2 JSON and gRPC, byte-identical to the golden, including the two redaction cases; a scope and reference test covers a scope mismatch, a reference under a configured root, a
..reference and a missing file.Local checks:
make gate,cargo fmt --all --check, clippy-D warnings, the fullrustev-serveandrustev-contracttest suites,spec-spine coupleandscripts/check-authored-content.sh.