Skip to content

feat(webapp): attribute console approvals to a reviewer identity#556

Merged
plind-junior merged 2 commits into
testfrom
feat/console-reviewer-identity
Jul 24, 2026
Merged

feat(webapp): attribute console approvals to a reviewer identity#556
plind-junior merged 2 commits into
testfrom
feat/console-reviewer-identity

Conversation

@plind-junior

@plind-junior plind-junior commented Jul 24, 2026

Copy link
Copy Markdown
Member

lets a human approving in the review console be attributed to a reviewer identity, so the self-approval gate stops wrongly blocking the KB owner.

the problem: the console approves through the server's kb.approve, which stamps the approver as the request actor — and with no identity supplied, that falls back to the tokenless unknown-agent default. proposals captured under the same unknown-agent sentinel then collide with it, so approving them trips forbidden_self_approval. the owner could approve their own KB's claims from the CLI (where the OS user is a distinct actor) but not from the UI. "if not me, who?" — it should be them; the fix is to give them an identity, not to loosen the gate.

the server already reads an X-Vouch-Agent header into the request actor; the console just never sent it. now:

  • rpc() sends x-vouch-agent: <reviewer> on every call
  • the dev proxy forwards that header (it previously dropped it, keeping only content-type + authorization)
  • a small topbar input lets the reviewer set their name, persisted in localStorage, defaulting to console

approvals are attributed to a distinct human reviewer, pass the gate for every proposal, and the audit log records who approved.

verified end-to-end against a running vouch serve: approving a previously-blocked unknown-agent proposal in the UI now succeeds, and the audit event records actor: console. tests add proxy header-forwarding and rpc reviewer-header cases. full webapp suite green (156), tsc clean.

note: stacks on #555 (the {items} envelope render fix) — the pending page can't render to approve from without it. rebases to just this change once #555 merges.

Summary by CodeRabbit

  • New Features

    • Added a reviewer identity field in the console header for attribution of approvals and proposals.
    • Reviewer identity is now sent with requests and preserved through the proxy.
  • Bug Fixes

    • Improved compatibility with list responses returned in either wrapped or legacy array formats.
    • Preserved session-list response envelopes while avoiding unintended unwrapping for other methods.

kb.list_* moved from a bare array to a `{items, _meta}` dict envelope
(server deprecation, remove_in 1.4.0), but the webapp still typed and
consumed these as flat arrays — so `r.data.map` in Shell and PendingView
threw "map is not a function", crashing the whole tree through the error
boundary on every page, the pending queue included.

unwrap `items` once in rpc(), scoped to kb.list_* methods, tolerating the
old bare-array shape and leaving kb.list_sessions ({sessions}) and non-list
object results untouched. one central change fixes the pending page and
every list view; the fan-out, optimistic caches, and views are unaffected.
a human approving in the review console was anonymized to the tokenless
`unknown-agent` default, which collides with proposals filed under the same
sentinel and trips the self-approval gate — so the owner literally could not
approve their own KB's captured claims from the UI ("if not me, who?").

the console now carries a reviewer identity: rpc() sends it as X-Vouch-Agent
(which the server already reads into the request actor), the dev proxy
forwards that header, and a small topbar input lets the reviewer set their
name, defaulting to `console`. approvals are attributed to a distinct human
reviewer, pass the gate for every proposal, and the audit log records who
approved — the review gate working correctly, not loosened.
@github-actions

Copy link
Copy Markdown

this PR changes UI (web/, src/vouch/web/, or webapp/) but has no before/after screenshots in the description. UI changes are reviewed by screenshot, not by running the app. add before and after screenshots, then reopen.

@github-actions github-actions Bot closed this Jul 24, 2026
@github-actions github-actions Bot added the size: S 50-199 changed non-doc lines label Jul 24, 2026
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d439e810-e6b8-420c-809d-687b6b809a21

📥 Commits

Reviewing files that changed from the base of the PR and between 40c9df0 and 7420085.

📒 Files selected for processing (5)
  • webapp/plugins/vouch-proxy.test.ts
  • webapp/plugins/vouch-proxy.ts
  • webapp/src/components/Shell.tsx
  • webapp/src/lib/rpc.test.ts
  • webapp/src/lib/rpc.ts

Walkthrough

The web console now stores a reviewer identity, sends it as X-Vouch-Agent through RPC and proxy requests, and supports compatible kb.list_* response envelopes. Tests cover reviewer header propagation and list-result handling.

Changes

Reviewer identity and RPC compatibility

Layer / File(s) Summary
RPC identity and response handling
webapp/src/lib/rpc.ts, webapp/src/lib/rpc.test.ts
Adds reviewer identity helpers and headers, trims stored identities, and unwraps { items } for compatible kb.list_* responses while preserving other result shapes.
Shell reviewer input
webapp/src/components/Shell.tsx
Adds a controlled reviewer identity input initialized from persisted state and updates the stored identity on change.
Proxy header forwarding
webapp/plugins/vouch-proxy.ts, webapp/plugins/vouch-proxy.test.ts
Forwards x-vouch-agent to the upstream endpoint and verifies the echoed reviewer identity in proxy tests.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Reviewer
  participant Shell
  participant rpc
  participant vouch-proxy
  participant VouchEndpoint
  Reviewer->>Shell: Enter reviewer identity
  Shell->>rpc: Persist reviewer identity
  rpc->>vouch-proxy: Send RPC request with x-vouch-agent
  vouch-proxy->>VouchEndpoint: Forward x-vouch-agent
  VouchEndpoint-->>vouch-proxy: Return response
  vouch-proxy-->>rpc: Return proxied response
Loading

Possibly related PRs

  • vouchdev/vouch#555: Contains the same kb.list_* response unwrapping behavior in the RPC implementation and tests.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/console-reviewer-identity

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

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

this PR changes UI (web/, src/vouch/web/, or webapp/) but has no before/after screenshots in the description. UI changes are reviewed by screenshot, not by running the app. add before and after screenshots, then reopen.

@plind-junior plind-junior reopened this Jul 24, 2026
@github-actions

Copy link
Copy Markdown

this PR changes UI (web/, src/vouch/web/, or webapp/) but has no before/after screenshots in the description. UI changes are reviewed by screenshot, not by running the app. add before and after screenshots, then reopen.

@github-actions github-actions Bot closed this Jul 24, 2026
@plind-junior
plind-junior merged commit 74c0106 into test Jul 24, 2026
27 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: S 50-199 changed non-doc lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant