Skip to content

feat(workspace): S-1 response-file client + M-13 opt-in excerpt export - #293

Merged
brianluby merged 2 commits into
mainfrom
feat/f12-f13-s1-m13
Nov 14, 2026
Merged

brianluby merged 2 commits into
mainfrom
feat/f12-f13-s1-m13

Conversation

@brianluby

Copy link
Copy Markdown
Collaborator

Re-opened from #290 (auto-closed when its stacked base feat/f12-f13-m10-adapters was deleted on #288 merge). Rebased onto current main; M-10 is already merged.

S-1: POST /api/v2/review-queue/responses (CM-53 writeReviewResponse) writes one immutable portable response through the shared respond() path for all four closed families. Security preserved (loopback, exact-Host, write-scoped capability, confinement, no-replace).
M-13: opt-in bounded source excerpts (forge trace --include-source-excerpts + v2 include_source_excerpts); conservative IdsAndHashes default byte-identical.

CodeRabbit findings remediated: v1/v2 route mismatch fixed (handler now reachable on the documented v2 path) + dispatch test; operation count 65->66.

Verification: 10 S-1/M-13 tests green; full suite green; fmt/clippy clean.

S-1: add POST /api/v2/review-queue/responses writing one immutable portable
review response through the shared respond()/RespondOptions path for all four
closed families (/1 review, /2 lifecycle, /3 authoring, /4 edit). Preserves
loopback, exact-Host pin, project confinement, write-scoped capability and
native no-replace publication. New CM-53 writeReviewResponse operation; v1
contract frozen. No new review-family wire contract.

M-13: explicit opt-in bounded source excerpts for trace exports. CLI
--include-source-excerpts and v2 ExportRequest.include_source_excerpts; the
conservative IdsAndHashes default is retained and byte-identical (no excerpts
field). Excerpts are trace-only, bounded (100 items, 500 chars), untrusted.

Tests: S-1 round-trip + confinement/auth/no-replace refusals; M-13 default
byte-identical vs opt-in excerpts. fmt/clippy clean; full suite green except
the confirmed-flaky workflow::fake test (passes in isolation, untouched).
CodeRabbit PR #290: the S-1 dispatcher matched the private canonical key
unconditionally, so a v2 launch admitted /api/v2/review-queue/responses
against the OpenAPI contract but never reached write_response, while the
frozen v1 namespace kept an unintended alias. Gate the route on
ApiMajor::V2 and the exact /api/v2/review-queue/responses wire path,
mirroring the other v2 mutation routes; transport admission (loopback,
exact-Host pin, write-scoped capability) and the handler's confinement
fences are unchanged. Add a dispatch-level test: v2 POST publishes and
round-trips the response, v1 is refused not-found.

Capability matrix doc: current API2.4 draft total 65 -> 66 with CM-53
writeReviewResponse (matches the OpenAPI count and contract tests).
Copilot AI balanced review requested due to automatic review settings November 14, 2026 23:45
@coderabbitai

coderabbitai Bot commented Nov 14, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 40 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 34d796eb-39cd-4b4e-a340-3aa417cabb39
Commits

Reviewing files that changed from the base of the PR and between d28baf0 and 5d0c573.

Files ignored due to path filters: 3

  • docs/api/capability-matrix-v2.json is excluded by !docs/**
  • docs/api/capability-matrix-v2.md is excluded by !docs/**
  • docs/api/forge-workspace-v2.openapi.yaml is excluded by !docs/**
Files selected for processing: 8

  • src/cli/mod.rs
  • src/cli/trace.rs
  • src/workspace/actions.rs
  • src/workspace/domain.rs
  • src/workspace/http.rs
  • src/workspace/http_review.rs
  • src/workspace/reports.rs
  • tests/api_contract_validation.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@brianluby
brianluby merged commit 7be643c into main Nov 14, 2026
19 of 23 checks passed
@brianluby
brianluby deleted the feat/f12-f13-s1-m13 branch November 14, 2026 23:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

4 open issues
What changed in this PR

Adds an S-1 v2 API endpoint to write confined portable review response files via the shared respond() pipeline, and introduces M-13 opt-in bounded source excerpts for trace exports while keeping the default export byte-identical.

Changes:

  • Add POST /api/v2/review-queue/responses (writeReviewResponse) handler + dispatch + contract/docs updates.
  • Add opt-in include_source_excerpts plumbing for trace exports, plus excerpt extraction/validation and CLI flag support.
  • Update API contract validation expectations and capability matrix to include the new operation.
File Description
tests/​api_contract_validation.rs Updates expected operation counts to include the new v2 operation.
src/​workspace/​reports.rs Adds optional excerpts field, v1/v2 contract validation split, excerpt validation, and tests.
src/​workspace/​http_review.rs Introduces S-1 response-file write handler + tests validating confinement, refusal behavior, and routing.
src/​workspace/​http.rs Wires the new v2 route into dispatch.
src/​workspace/​domain.rs Implements bounded trace source excerpt extraction (M-13).
src/​workspace/​actions.rs Adds include_source_excerpts request handling and renders reports with optional excerpts.
src/​cli/​trace.rs Adds --include-source-excerpts output formatting for trace CLI.
src/​cli/​mod.rs Adds CLI flag plumbing for include_source_excerpts.
docs/​api/​forge-workspace-v2.openapi.yaml Documents the new endpoint, error code, request flag, and report excerpts schema.
docs/​api/​capability-matrix-v2.md Updates operation totals and adds CM-53 entry.
docs/​api/​capability-matrix-v2.json Adds writeReviewResponse to the CI denominator list and declares CM-53.

Review effort: Lite

Comment thread src/workspace/reports.rs
Comment on lines +129 to +145
if let Some(excerpts) = &self.excerpts {
if self.kind != "trace" || excerpts.len() > 100 {
return Err(Error::invalid());
}
for excerpt in excerpts {
let object = excerpt.as_object().ok_or_else(Error::invalid)?;
if object.len() != 5
|| object["element_id"].as_str().is_none_or(|s| s.is_empty() || s.len() > 200)
|| object["source_file"].as_str().is_none_or(|s| s.is_empty() || s.len() > 512)
|| object["source_line"].as_u64().is_none_or(|n| n == 0 || n > 1_000_000)
|| object["text"].as_str().is_none_or(|s| s.len() > 500)
|| object["truncated"].as_bool().is_none()
{
return Err(Error::invalid());
}
}
}
Comment on lines +2774 to 2790
{
"if": {
"properties": {
"excerpts": {}
},
"required": [
"excerpts"
]
},
"then": {
"properties": {
"report_kind": {
"const": "trace"
}
}
}
}
Comment thread src/workspace/domain.rs
Comment on lines +517 to +530
pub(crate) fn trace_excerpts(snapshot: &Snapshot) -> Result<Vec<serde_json::Value>> {
let mut excerpts = Vec::new();
for item in snapshot.items.iter().filter(|item| {
matches!(item.registration.role, Role::OscalCatalogArtifact | Role::OscalComponentArtifact)
}) {
for entry in trace_entries(item)? {
let Some(trace) = entry.trace else { continue };
let Some(source) = trace_source(snapshot, &trace) else { continue };
let text = std::str::from_utf8(&source.captured.bytes).map_err(|_| invalid())?;
let lines: Vec<&str> = text.lines().collect();
if !crate::trace::resolver::validate_line_reference(trace.source_line, lines.len()) {
continue;
}
let Some(line) = trace.source_line else { continue };
Comment thread src/workspace/reports.rs
Ok(pins)
}

#[cfg(test)]
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.

2 participants