Skip to content

spec(042): name the explanation request and answer documents (3.8.3) - #404

Merged
bartekus merged 1 commit into
mainfrom
spec/042-serve-explain
Oct 30, 2026
Merged

bartekus merged 1 commit into
mainfrom
spec/042-serve-explain

Conversation

@bartekus

Copy link
Copy Markdown
Contributor

Amends approved spec 042 section 3.8.3. Needs the owner's ratification before it is implemented.

The approved text says POST /v1/explain "takes the evidence and query of the spec implementing D2 (proposed as spec 040)" and returns "that spec's explanation record canonical bytes unchanged and its Markdown rendering", without naming a request or an answer document. The operation table has no request schema for it, so the route cannot be implemented as written. Spec 040 (now implemented) leaves the envelope to this spec in 040 3.15.3, quoted in the diff.

The amendment:

  • Request rustev.serve-explain/1: { evidence, query, options }, the shape spec 040 3.15.2 gives the bindings. evidence is { record, plan? } or { bundle }, each member embedded or a resolver reference (3.8.2). query is 040 3.3's query or { diff: { other } }. options is { scope, now_ms } exactly when a side is a bundle (040 3.16.2), and invalid_request otherwise.
  • Scope: options.scope must equal the host-resolved scope of the caller's principal, as for replay; otherwise decision_not_found.
  • Redaction: taken from the listener's configured redaction_policy, never from the body. With none, the explanation is unredacted (the library default).
  • Answer rustev.serve-explanation/1: { explanation, markdown }, with the rustev.explanation/1 canonical bytes embedded unchanged. A spec 040 refusal is invalid_document with the refusal code string in detail.

When implemented, the operation table (request rustev.serve-explain/1, response rustev.serve-explanation/1) and the generated .proto comments change with it.

Alternatives the owner may prefer: return the bare rustev.explanation/1 body and put the Markdown behind a separate route or Accept value; or take redaction from the body when the listener has none.

@github-actions

Copy link
Copy Markdown

AI review (findings)

The diff revises section 3 of spec 042 to specify the POST /v1/explain transport. I checked:

  1. Inline amendment note in spec body. The added text opens with "(amended 2026-10-29; the approved text named the inputs as … without naming either document)." The contract is explicit: "An amends edge is declared once, in the amending spec's frontmatter; the amended spec.md is not edited to record it." Embedding a prose description of what the prior approved text said — and why it was changed — is precisely what that rule prohibits. The editorial history belongs in git and in the amending spec's amends frontmatter edge, not inline in the spec body.

  2. options presence rule. The sentence "given when no side is a bundle, or missing when one is, the request is invalid_request" is consistent with spec 040 3.16.2 ("when neither is, all of them are refused; when either side is a bundle, --now-ms is required"). No defect here.

  3. Scope mismatch error code. Returning decision_not_found when options.scope diverges from the host-resolved scope matches the replay pattern cited (3.8.1) and is an intentional information-hiding choice. No defect.

  4. New document type names. rustev.serve-explain/1 and rustev.serve-explanation/1 are introduced. The repo context listing is truncated so I cannot confirm those schemas are absent from the tree; I do not report that.

{"head": "0095e3ea7af948655714494fadc0a6194f10f945", "verdict": "findings", "findings": [{"path": "specs/042-decision-service-and-remote-seams/spec.md", "line": 557, "summary": "Inline amendment note records prior approved text in the spec body, violating the contract rule that the amended spec.md is not edited to record its own amendment history."}]}

Subject: ca81e1e...0095e3e, diff digest 5804dcc3fd26289c5a786993149c0731e8e558266718ea1ede3208f93e6b1d39, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 30, 2026 02:38 — with GitHub Actions Error
@bartekus
bartekus force-pushed the spec/042-serve-explain branch from 0095e3e to 8e5d94b Compare October 30, 2026 02:40
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reading through the diff, the spec replaces a brief description of POST /v1/explain with a detailed normative breakdown of the request/response envelopes, scope enforcement, redaction, and gRPC framing.

Checking for internal consistency and security:

Options presence rule: The sentence "options holds scope and now_ms exactly when a side is in bundle form … given when no side is a bundle, or missing when one is, the request is invalid_request" is consistent with the quoted spec 040 3.16.2 rule ("when neither is, all of them are refused"). Parsing is awkward but logically sound.

Scope enforcement: "options.scope must equal the scope the host resolves for the caller's principal … otherwise the answer is decision_not_found" correctly gates bundle-form requests. When neither side is a bundle, scope is absent from options but references are still restricted to the caller's principal scope by the following sentence. No escalation path.

Redaction: Correctly migrated from the caller-supplied field to the per-listener configuration (3.15), with a sane default of unredacted when none is configured.

Error mapping: Spec 040 refusals mapped to invalid_document (carrying the refusal code in detail) is a new decision not present in the original text. I cannot verify whether other operations in 3.x use the same mapping from the hunk alone, but there is no self-contradiction within the changed text.

Security: No cross-scope information leak path is introduced; the scope check (decision_not_found on mismatch) fires before any resolution or explanation is performed.

No concrete defect found in the supplied evidence.

{"head": "8e5d94bcc46e3927847570a6f3d181519c12005c", "verdict": "no-findings", "findings": []}

Subject: ca81e1e...8e5d94b, diff digest 90c825cceb4c8a15a4821e33fbe10aabf3244bab54ad9c6da92145d102bfab00, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Oct 30, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 30, 2026
@bartekus
bartekus force-pushed the spec/042-serve-explain branch from 8e5d94b to 9d19156 Compare October 30, 2026 03:34
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff, which replaces the terse prose description of POST /v1/explain with a detailed request/response specification, including named schema types, scope enforcement, redaction rules, and gRPC transport.

Key points examined:

Logic of options biconditional (scope + now_ms vs. bundle presence)
The spec states scope and now_ms are held "exactly when a side is in bundle form," and the invalidity condition is correctly stated as the negation: "given when no side is a bundle, or missing when one is." The biconditional is internally consistent.

Scope enforcement
The spec separates two distinct checks: (1) format check on options.scope/now_ms presence → invalid_request; (2) scope value check against the caller's authorized principal → decision_not_found. This matches the general pattern from spec 010 3.7.2 cited in both old and new text.

Security: no caller-supplied redaction policy
"The request carries no redaction policy and no store resolver" is a correct security property — the redaction policy is resolved from the listener configuration, not from caller input, preventing a caller from bypassing redaction.

Refusal surfacing
"A spec 040 refusal (3.17) is invalid_document carrying the refusal code string in detail" is a design decision about transport-layer error mapping. Nothing contradicts the governance documents here.

Generated schema files
rustev.serve-explain/1 and rustev.serve-explanation/1 are referenced but no corresponding .schema.json files appear in the diff. Governance context confirms generated schema files are excluded from AI review and verified separately — this is not a finding.

No concrete defect, security problem, or governance inconsistency found.

{"head": "9d19156e495f57185259bd9c801a90cbf8850462", "verdict": "no-findings", "findings": []}

Subject: 8cd9c0c...9d19156, diff digest 7e6af556eb1e7ddb8ca3fcf94e3a34575bf5cc0f671441fa04d7940b24581fc6, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Oct 30, 2026
Merged via the queue into main with commit 0f2440a Oct 30, 2026
30 checks passed
@bartekus
bartekus deleted the spec/042-serve-explain branch October 30, 2026 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant