Skip to content

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

Closed
brianluby wants to merge 2 commits into
feat/f12-f13-m10-adaptersfrom
feat/f12-f13-s1-m13
Closed

brianluby wants to merge 2 commits into
feat/f12-f13-m10-adaptersfrom
feat/f12-f13-s1-m13

Conversation

@brianluby

Copy link
Copy Markdown
Collaborator

Stacked on M-10 PR #288 (base feat/f12-f13-m10-adapters). Delivers two deferred F12/F13 items in the workspace/CLI surface. Tickets #21 (F12) / #59 (F13).

S-1 — interactive workspace response-file client

  • New POST /api/v2/review-queue/responses (writeReviewResponse, capability-matrix CM-53) writes one immutable portable review response through the same shared respond()/RespondOptions path the CLI uses, selecting the closed /1 review, /2 lifecycle, /3 authoring or /4 edit family.
  • Preserves every existing workspace security contract: loopback transport, exact-Host pin, project confinement (validate_path + review capture), write-scoped capability/session auth (guard is_mutation), participating exclusive project lease, and native no-replace publication. Existing destinations are refused.
  • No new review-family wire contract — the response file is the existing portable response; the route is a thin confined writer over the shared command.
  • v1 contract frozen (39 ops, 1.2.0); the operation is v2-only additive (2.4.0 unreleased, extended without a version bump).

M-13 — opt-in sensitive/excerpt export

  • Explicit opt-in only: CLI forge trace --include-source-excerpts and v2 ExportRequest.include_source_excerpts. The conservative IdsAndHashes default is retained and byte-identical (the default envelope omits the excerpts field entirely).
  • Excerpts are trace-only, bounded (≤100 items, ≤500 chars/line, char-boundary safe), labeled untrusted, and inherit the source policy's sensitivity. Default export validates against the frozen v1 envelope; opt-in against v2.
  • redaction_summary drops source-excerpts from removed categories only when opted in.

Tests

  • S-1: response-file write round-trip through the shared respond path (decodable by the closed review decoder) + confinement, mismatched-family, no-replace, read-only-session and invalid-capability refusals.
  • M-13: default export byte-identical with no excerpts vs opt-in including bounded excerpts; non-trace excerpt refusal.

Verification

  • cargo fmt --check clean; cargo clippy --all-targets -- -D warnings clean.
  • Full cargo test: all workspace/review/report/contract tests green. The single failure (workflow::fake::tests::oversized_response_and_timeout_are_refused) is the confirmed-flaky workflow test under concurrent load — it passes in isolation and src/workflow/ is untouched. Committed with the authorized SKIP_FORGE_PRECOMMIT=1 for this verified commit only; CI runs full gates.
  • No new crate dependencies.

Human gates (reviewer authority, team exercises, security/privacy, WCAG/AT, final docs review) remain open; passing code does not establish domain approval.

@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

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: ef441fad-9cf9-43ec-a37d-52a7a2cf3535

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • 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

Copy link
Copy Markdown
Collaborator Author

Code review: S-1 response-file client + M-13 excerpt export — Request changes (minor)

Reviewed http_review.rs, the dispatch/guard changes in http.rs, actions.rs, domain.rs, reports.rs, cli/trace.rs and the new tests. (Stacked on #288.)

Should fix

  1. The export summary overclaims. With excerpts opted in, redaction_summary.removed_categories is ["reviewer-names","absolute-paths","secrets"], but the excerpts are raw source lines with no scrubbing (domain.rs::trace_excerpts). If a traced source line contains a secret, it is exported while the summary says secrets were removed. Drop secrets from the list when opted in (or scrub/warn), and consider flagging the artifact as sensitive.

  2. CLI excerpts re-read the source unbounded. cli/trace.rs::format_source_excerpts calls std::fs::read_to_string(&report.source_path) after the report was generated, so (a) the read has no size cap and (b) the excerpt can come from different bytes than the traced/hashed source (TOCTOU). The workspace path already uses captured bytes; reuse the bytes the report was built from.

Test gap

  1. No test shows that a v1 session refuses POST /api/v2/review-queue/responses. I checked the gating by reading the code (wire path → private path, contract admission before dispatch, and is_mutation treats the POST as write-scoped), so it appears correct, but a regression test would pin the "v1 frozen at 39 ops" claim.

What looks good

The route is a thin confined writer over the shared respond() path, paths are validated and project-confined, publication is no-replace under the project lease, refusals are collapsed to a fixed safe message (no rationale leakage), and default exports stay byte-identical with a test.


Generated by Claude Code

@brianluby
brianluby marked this pull request as ready for review November 14, 2026 22:15
Copilot AI balanced review requested due to automatic review settings November 14, 2026 22:15
@brianluby

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

Note

Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

🟡 Changes recommended

The change cannot be approved because a critical routing mismatch makes the new writeReviewResponse endpoint unreachable for v2 clients, and there is also an outstanding documentation inconsistency in the capability matrix total operation count.

2 open issues
What changed in this PR

Adds two workspace/CLI surface enhancements: an interactive workspace endpoint to publish portable review response files via the shared respond() path, and an explicit opt-in to include bounded source excerpts in trace exports while keeping the default export byte-identical and excerpt-free.

Changes:

  • Adds writeReviewResponse as a new workspace POST endpoint for writing one immutable portable review response file.
  • Introduces opt-in include_source_excerpts for trace exports (API + CLI), with bounded excerpt generation and v1/v2 validation behavior.
  • Updates v2 OpenAPI, capability matrix, and contract tests to reflect the expanded v2 surface area and operation count.
File Description
tests/​api_contract_validation.rs Updates API contract validation expectations to account for the newly added v2 operation(s).
src/​workspace/​reports.rs Extends the workspace report/export envelope to optionally include source excerpts and handles v1 vs v2 validation/rendering accordingly.
src/​workspace/​http.rs Wires the new review-response write endpoint into the workspace HTTP dispatcher routing.
src/​workspace/​http_review.rs Implements the confined writeReviewResponse handler that publishes a portable response file via the shared review respond() flow and maps handler errors to HTTP responses.
src/​workspace/​domain.rs Adds bounded extraction of source-line excerpts from captured sources for opt-in trace exports.
src/​workspace/​actions.rs Threads the include_source_excerpts option through export handling and redaction summary behavior.
src/​cli/​trace.rs Adds --include-source-excerpts support to the trace CLI output, formatting and appending excerpts when opted in.
src/​cli/​mod.rs Exposes and wires the new trace subcommand flag for including source excerpts through CLI execution.
docs/​api/​forge-workspace-v2.openapi.yaml Documents the new v2 review-response write endpoint and the opt-in excerpts field/flag in the v2 API schema.
docs/​api/​capability-matrix-v2.md Adds the CM-53 capability entry for writeReviewResponse and updates the documented v2 operation surface description.
docs/​api/​capability-matrix-v2.json Adds CM-53 / writeReviewResponse to the machine-readable capability matrix and operation sets.

Review effort: Balanced

Comment thread src/workspace/http.rs Outdated
Comment on lines +967 to +973
if method == "POST" && path == "/api/v1/review-queue/responses" {
return review::write_response(
state,
payload.as_ref().ok_or_else(Error::invalid)?,
read_deadline,
);
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in bf7623e: removed the ungated /api/v1 match (it compared the canonical key, so v2 requests fell through to not-found and v1 hit an unintended alias). Added the route in the v2 section mirroring the existing v2 mutation pattern: state.api_major == ApiMajor::V2 && POST && wire_path == "/api/v2/review-queue/responses" -> review::write_response, exactly the documented OpenAPI path. Security guards untouched (loopback, exact-Host, write-scoped capability, confinement, no-replace). New test response_write_dispatches_on_the_v2_wire_path_only: v2 POST returns 200 + published file decodes; v1 POST refused not-found (v1 frozen at 39 ops). Full suite green.

| CM-50 | Discard an unconfirmed source stage | cross-cutting | US-7, US-9, US-10, US-13 | `discardProjectSourceTransferStage` | browser-write |
| CM-51 | Prepare and confirm an exact staged-profile source export | cross-cutting | US-7, US-9, US-10, US-13 | `prepareProjectSourceStreamExport`, `getOperation`, `getEffectPreview`, `commitEffectPreview` | browser-write |
| CM-52 | Read manifest and exact parts of a committed staged-source export | cross-cutting | US-7, US-9, US-10, US-13 | `getProjectSourceStreamExportManifest`, `getProjectSourceStreamExportChunk` | browser-read |
| CM-53 | Write one portable review response file from the interactive client | cross-cutting | US-4, US-13 | `writeReviewResponse` | browser-write |

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in bf7623e: "65 total" -> "66 total", verified against the OpenAPI doc (66 operations incl. writeReviewResponse) and contract tests (assert_eq!(second.len(), 66)). The 65s in compatibility.md/architecture.md are dated checkpoint records pinned to commit 304b31f (historical, correct as-is) — left untouched.

brianluby added a commit that referenced this pull request Nov 14, 2026
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).
@brianluby
brianluby force-pushed the feat/f12-f13-m10-adapters branch from 8d3692e to 33d4bfd Compare November 14, 2026 23:39
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).
@brianluby
brianluby deleted the branch feat/f12-f13-m10-adapters November 14, 2026 23:41
@brianluby brianluby closed this Nov 14, 2026
brianluby added a commit that referenced this pull request Nov 14, 2026
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).
brianluby added a commit that referenced this pull request Nov 14, 2026
#293)

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

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).

* fix(workspace): dispatch S-1 response writes on the documented v2 path

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).
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