Skip to content

CONTRACT: feat(ui-server, ui-react, ui-kit): an honest poster and target kind on the GitHub comment approval (#4154) - #4198

Merged
schlessera merged 6 commits into
mainfrom
feat/4154-comment-preview-author
Nov 18, 2026
Merged

schlessera merged 6 commits into
mainfrom
feat/4154-comment-preview-author

Conversation

@schlessera

@schlessera schlessera commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Closes #4154. Part of #3791.

What changed

A brain_github_issue_comment approval card now says who would post the comment and whether it goes on an issue or a pull request, but only when the host verified each fact. Otherwise it shows kit-owned neutral states, following the maintainer's ruling on #4154 (author options 1 + 2, target-kind option A).

  • Wire / SDK (additive): tool_approval_request and PermissionRequest gain the optional display: ApprovalDisplay, shaped { github?: { poster: { login, is_bot } | null, target: { kind, html_url } | null } }. The client schema turns a malformed fact into null. It never drops the card.
  • Host (packages/ui-server/src/github/host.ts):
    • Poster: GET /user with the same token the write will use. The result is kept in a single-entry cache keyed by the token's SHA-256 digest:
      • a verified poster is reused for 10 min;
      • a failed lookup is not repeated for 1 min;
      • another credential replaces the entry and never reads it;
      • a 401 on the write clears it.
    • Target: GET /repos/{repo}/issues/{n}. The kind counts only when GitHub's answer names that same repository and number. The html_url goes through githubDirectUrl.
    • Limits: both lookups run in parallel under one 3 s limit, and any failure gives null. Neither fact enters input, the comparison that detects an edited approval, the outward_action record, or the tool result.
  • Kit:
    • GitHubComment in preview accepts no author and names "The host's GitHub account". It never shows @ghost for an unknown poster. A preview also shows its whole draft, since the posted-comment 10,000-character cut would hide part of an approved body of up to 65,536 characters.
    • GitHubRef accepts kind: null and renders repository #number with no kind, no chip and no link, whatever htmlUrl says.
    • New W4 stories cover each combination at 320px and desktop.
  • Renderer: the store keeps the frame's display on the card and replaces it on re-delivery. W4 renders the kit's GitHubRef target row above the kit's GitHubComment preview, and maps only the facts the host reported. The poster asks for no avatar, because the avatar route serves only logins a tool result named. The posted-comment card's unknown kind now uses the kit state too, and its behaviour is unchanged.

Why this shape

  • Display data rides beside input, not inside it. The approval's exact-content comparison and its record stay byte-for-byte what they were, and nothing new is added to what the model sees.
  • The target lookup asks the turn's data routing (G2). This is the one judgment call for the reviewer. The lookup sends the model-chosen repository and number to GitHub before the card, and under an owner/* allow-list the repository name is model text. So it gets the same check a read gets. A refusal only leaves the kind unknown; the write is still unrouted, per the ui-server: apply provider-policy data routing (G2) to the host GitHub tools #4029 ruling. The test that asserted writes never ask routing (GITHUB_WRITE_NEVER_ASKS_ROUTING) became GITHUB_WRITE_ROUTING_ONLY_FOR_DISPLAY. Its siblings in the same test still prove the write's result, card and request are unchanged under a refusal. They also prove a refused turn sends no target lookup.
  • No title or state on the target row. The ruling covers poster and kind only, so the row is GitHubRef's inline form. Adding the target's title would put more untrusted GitHub text on the card, which is a separate decision.

Proof

bun run check:pr --base origin/main   # passed; receipt below

Mutation receipts. Each mutation was applied, the named assertion failed, and the source was restored.

Host mutations (packages/ui-server/tests/github-write-tools.test.ts, each restored after):

  • M1 poster cache ignores the credential key -> GITHUB_POSTER_BOUND_TO_CREDENTIAL fails
  • M2 display copied into the model-facing result -> GITHUB_DISPLAY_NOT_RETURNED fails (and GITHUB_WRITE_NOT_ROUTED, the comment exact-result test)
  • M3 target kind accepted without repository/number binding -> GITHUB_TARGET_NEUTRAL (moved / another number) fails
  • M4 target lookup skips data routing -> GITHUB_WRITE_ROUTING_ONLY_FOR_DISPLAY fails
  • M5 rejected credential keeps its cached poster -> GITHUB_REJECTED_CREDENTIAL_FORGOTTEN fails
  • M6 failed lookup not held for its retry window -> GITHUB_FAILED_LOOKUP_NOT_REPEATED fails
  • M7 approvalRequestFrame drops display -> APPROVAL_DISPLAY_ON_FRAME (ws-allowlist-enforcement) and GITHUB_APP_COMMENT_DISPLAY (ws-github, pi and claude) fail
  • M8 schema without .catch on display -> APPROVAL_DISPLAY_NEVER_DROPS_THE_CARD fails (ui-sdk server-schemas)
    Client mutations (each restored after):
  • R1 W4 renderer defaults an unknown kind to "issue" -> W4_UNKNOWN_KIND (and the existing "the approval names a number, not its kind") fail (ui-react tests/render/github-tools.test.tsx)
  • R2 W4 renderer draws an unknown poster as { login: null } -> W4_NO_FACTS_HOST_ACCOUNT, W4_POSTER false * fail
  • R3 W4 renderer skips the contract validator on the target link -> W4_TARGET_LINK_VALIDATED fails
  • R4 store keeps a previous card's display on re-delivery -> APPROVAL_DISPLAY_ABSENT_IS_UNKNOWN fails (tests/restored-approval-store.test.ts)
  • R5 frame handler drops msg.display -> APPROVAL_DISPLAY_STORED fails
  • K1 kit GitHubRef keeps htmlUrl for kind null -> KIT_UNKNOWN_KIND_NO_LINK, KIT_UNKNOWN_KIND_ROW_NO_LINK fail (ui-kit tests/github-neutral-states.test.tsx)
  • K2 kit draws an absent preview author as the ghost -> KIT_HOST_ACCOUNT_NAME fails
  • K3 kit cuts a preview body at COMMENT_MAX_CHARS -> KIT_PREVIEW_EXACT_BODY fails
  • K2 in a real browser (storybook dark): unknown preview author as ghost -> 6 W4 neutral-poster stories fail 'an unverified poster is never the deleted-account ghost'

Real browser. Host Chromium 1243, outside the command sandbox:

  • the kit storybook projects storybook (dark) and storybook-light, with the a11y gate at error, for GitHubWrite, GitHubThread and GitHubIdentity: 66/66 passed, covering every new W4 neutral state at 320px and at desktop width;
  • ui-react-layout tests/browser/github-tools.layout.tsx: 1/1 passed.

The github-write-comment visual subject gains the draft caption (see the review fix below). Its dark and paper baselines were regenerated in the pinned container. The subjects project then compared clean, 112/112. No other baseline moved.

Unit / integration:

  • ui-server github-write-tools (+16 tests for display facts: verified issue/PR, credential rotation, cache and retry windows, rejection forgetting, every lookup failure, deadline), github-tools-host, ws-github (end to end on pi and claude), ws-allowlist-enforcement (first delivery and re-delivery);
  • ui-sdk server-schemas;
  • ui-react render/github-tools (every known/unknown combination, link validation, exact body), restored-approval-store;
  • ui-kit github-neutral-states;
  • tests/api-surface.

All pass. In the same run, 49 failures are in ui-sdk worker/sandbox files that need bubblewrap user namespaces, which this host lacks. The same files fail 51 tests on the untouched base.

Provider-history guards. packages/ui-backend-claude/tests/provider-history.test.ts and packages/ui-backend-pi/tests/provider-history.test.ts cannot start a worker on this host: bwrap: No permissions to create a new namespace, worker_host_unsupported. They fail identically on the untouched base, inside and outside the command sandbox. Both guard files are unchanged, and hosted CI is their proof for this head. The display-leak mutations above (M2, R5, the APPROVAL_DISPLAY_NEVER_SENT_BACK and GITHUB_APP_DISPLAY_* assertions) are the local evidence that nothing reaches the model.

Review fix (record on this PR, head 483cabc01). One finding, fixed in 8bb0482e1. W4 had lost the "Brain's draft · not posted" caption when it moved onto GitHubComment, whose preview set caption={false}.

  • A GitHubComment preview now carries the same DRAFT_CAPTION that W1's draft body uses. Posted comments stay uncaptioned.
  • Failing first: on 483cabc01, KIT_PREVIEW_DRAFT_PROVENANCE (ui-kit github-neutral-states) and the six W4_DRAFT_PROVENANCE cases (ui-react render/github-tools) fail.
  • Mutations:
    • P1, the preview caption removed again: those same assertions fail.
    • P2, the draft caption leaks onto posted comments: "a posted comment is not Brain's draft" fails.
  • Real browser: the W4 story play functions now also assert the caption. The storybook and storybook-light projects pass 66/66 at 320px and desktop.
  • Same loss elsewhere: the W1 draft body already keeps the caption (object-parts.tsx). Every other GitHubComment caller renders posted comments: thread items, earlier-comment pages, line comments. GitHubReview has no preview.

G2 on the target lookup is now the maintainer's ruling on #4154; it is kept as built.

Refresh: merged origin/main at 0babedee2 (no rebase), cleanly. The typecheck with an 8 GB heap is clean, and check:pr was rerun at the merge head; the receipt below replaces the earlier one.

Merge with #4147 (squash ade18f34f). Merged origin/main at 51d0f6de6 (no rebase) into merge commit 191e4fdfa, whose parents are 44de7aef7 and 51d0f6de6.

Collisions (bun scripts/collisions.ts --json --pr <n>): at head 191e4fdfa, no path collisions. Two textual collisions remain:

Ten closure-only overlaps with older drafts.

Overlap with #4147 (per-review line-comment count, worked in parallel): both touch packages/ui-react/src/components/chat/tool-cards/github-cards.tsx. This PR changes only the write section at the end of that file (GithubCommentCard, GithubCommentPreview, the removed Target helper and the import list), and leaves the pull-request read card alone.

{"version":1,"kind":"brain-check-pr-receipt","head":"191e4fdfa3f980ff2b701b24c0f81a86e989cb26","base":"origin/main","mode":"focused","startedAt":"2026-11-17T22:21:26.559Z","finishedAt":"2026-11-17T22:22:46.217Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":14738.123044},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":127.02482900000177},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":110.10915699999896},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":21.071403999998438},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":64644.236221}]}

Checklist

  • Focused local preflight/behavioral receipts passed; selected hosted proof is pending on this head.
  • Acceptance criteria from the issue are all met. The provider-history guards' local run is environment-blocked, as noted above.
  • Recorded independent review of this head (the orchestrator starts it).
  • Milestone 0.45.0 on this PR and ui-react, ui-server: an honest author for the W4 comment preview, so it can use GitHubComment preview #4154.
  • Changeset: .changeset/4154-comment-preview-author.md (minor: ui-sdk, ui-server, ui-kit, ui-react).
  • No personal data; leakage gate clean.
  • Contract index and components updated in the same CONTRACT: commit: docs/integration-contract.md, integration-contract/wire.md#approval-display-facts-additive-0450-4154 and integration-contract/mcp.md (GitHub writes, data routing), plus docs/hosting/README.md and the API report.
  • Docs reflect the change. Three citations my line shifts moved were repaired.
  • Guards: no new guard. The target lookup reuses the existing G2 routing check, and a refusal or failure narrows only one display fact to null. The approval, the write and the turn are unaffected.
  • Provider history: nothing is added to the provider-facing conversation. The facts stay host- and client-side.

Anything left open

🤖 Generated with Claude Code

…get kind on the GitHub comment approval (#4154)

The comment card now names who would post and on what, when the host can
verify each, and kit-owned neutral states otherwise.

- ui-sdk: `tool_approval_request` and `PermissionRequest` gain optional
  `display: ApprovalDisplay` (`github: { poster, target }`). Clients drop a
  malformed fact to null, never the card.
- ui-server: the comment card resolves the poster with `GET /user` through a
  single-entry cache keyed by the credential's digest (10 min, failures held
  1 min, forgotten when GitHub rejects the credential on a write), and the
  target kind with `GET /repos/{repo}/issues/{n}`, bound to that repository
  and number and asked of the turn's data routing first. Both share a 3 s
  limit; any failure is null and the write continues unchanged. Nothing
  reaches the input, the answer comparison, the outward_action record or
  the tool result.
- ui-kit: `GitHubComment` preview accepts no author ("The host's GitHub
  account", never @ghost) and shows its whole draft; `GitHubRef` accepts
  `kind: null` (`repository #number`, no chip, no link). W4 stories for every
  combination at 320px and desktop.
- ui-react: the store keeps the frame's facts on the card (replaced on
  re-delivery); W4 maps them onto the kit states, the target link through the
  contract validator. The posted card's unknown kind uses the kit state too.

Contract docs: wire (approval display facts), mcp (GitHub writes, data
routing), the index, the hosting guide, the API report and a minor changeset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera schlessera added this to the 0.45.0 milestone Nov 17, 2026
@schlessera schlessera added type: feat A new capability or a change in user-visible behaviour. area: ui-sdk Wire protocol, runtime schemas, the server and client SDK surfaces. area: ui-server Hono app factory: turn coordinator, auth, session catalog, routes, cron. area: ui-react React chat/files/voice components, stores, WebSocket transport. area: ui-kit The presentational design kit: components, tokens, Storybook, visual baselines. contract Touches the integration contract: CONTRACT: commit, contract doc updated in the same commit. labels Nov 17, 2026
@uploads-sh

uploads-sh Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

No uploads on this PR yet

This PR changes UI files (packages/ui-kit/src/github/GitHubComment.tsx, packages/ui-kit/src/github/GitHubIdentity.tsx, packages/ui-kit/src/github/GitHubRef.tsx and 6 more). Screenshots help reviewers see what changed.

  • From the CLI: uploads put before.png after.png --pr 4198
  • From an agent: ask it to attach screenshots with uploads.sh
  • By hand: drag images into the PR description and they're imported automatically
Tips for agents

Label each shot so reviewers know what they're seeing. Labels apply to every file in a call, so run one put per shot:

uploads put after.png --pr 4198 --meta path=/settings --state after --caption "Saved settings toast"
uploads put chat.png --pr 4198 --app ios --screen "Chat" --state after

No CLI? With the Uploads MCP, call sign_upload_url for files on disk (or put) with repo, pr: 4198 and the same screen, state and caption fields.

This comment updates with each upload, so you don't need to post the images yourself. A shot or two in the PR description is still welcome. Check what's attached with uploads list --pr 4198. More in the github-screenshots skill or the agent docs.

Workspace admins can turn this comment off in Settings → GitHub · docs

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 483cabc against base ec10940. Reviewer: agent. 1 finding: 0 fixed, 0 filed, 0 rejected, 1 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4198,
  "head": "483cabc01a7aaaa895911138589359c49b954324",
  "base": "ec109403df8c88a9dc17398e7578ac1f64efcfd9",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-kit/src/github/GitHubComment.tsx:57: W4 now uses this component, but caption={false} removes the previous “Brain's draft · not posted” provenance. The preview identifies the posting account without identifying Brain as the draft's source, contrary to #4154's explicit requirement to preserve draft provenance. Restore a preview-only draft caption in the kit."
    }
  ]
}

Review of 483cabc: W4 now renders through GitHubComment, whose preview
had `caption={false}`, so the card lost "Brain's draft · not posted". The
poster names whose account would post; the caption names who wrote it. A
preview now carries the same DRAFT_CAPTION W1's draft body uses; posted
comments stay uncaptioned. The github-write-comment visual baselines gain
the caption line, regenerated in the pinned container.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 483cabc against base ec10940. Reviewer: agent. 1 finding: 1 fixed, 0 filed, 0 rejected, 0 without a disposition.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4198,
  "head": "483cabc01a7aaaa895911138589359c49b954324",
  "base": "ec109403df8c88a9dc17398e7578ac1f64efcfd9",
  "reviewer": "agent",
  "outcome": "findings",
  "findings": [
    {
      "summary": "packages/ui-kit/src/github/GitHubComment.tsx:57: W4 now uses this component, but caption={false} removes the previous “Brain's draft · not posted” provenance. The preview identifies the posting account without identifying Brain as the draft's source, contrary to #4154's explicit requirement to preserve draft provenance. Restore a preview-only draft caption in the kit.",
      "disposition": "fixed",
      "commit": "8bb0482e1e1f88dd261c00926ee62340fe1558fc"
    }
  ]
}

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 44de7ae against base 0babede. Reviewer: agent. No findings.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4198,
  "head": "44de7aef77d7c3990a826306e991d6ef436355a2",
  "base": "0babedee2b94fb8ae06d3fac7c16917903e2f4e3",
  "reviewer": "agent",
  "outcome": "no-findings",
  "findings": []
}

…view-author

# Conflicts:
#	packages/ui-react/src/components/chat/tool-cards/github-cards.tsx
@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 191e4fd against base 51d0f6d. Reviewer: agent. No findings.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4198,
  "head": "191e4fdfa3f980ff2b701b24c0f81a86e989cb26",
  "base": "51d0f6de637509a97bed014eb0a284a196199e80",
  "reviewer": "agent",
  "outcome": "no-findings",
  "findings": []
}

@schlessera

Copy link
Copy Markdown
Owner Author

Fresh confirmation after an unrelated flake (orchestrator): confirmation run 44195552641 on head c74cf05764a26493bdd5bc97c32e54079ae26dac failed one unit test: packages/ui-server/tests/turn-boundary-hold.test.ts "a teardown that never finishes releases the hold at the boundary deadline" ("held before the deadline"). That test races a 50 ms real-time deadline against up to 20 real 1 ms sleeps, so a loaded runner fails it. This PR doesn't touch the hold or its test. The flake is filed as #4246, with no milestone, under the maintainer's ruling that timing flakes don't block milestoned work. The failed job was not rerun; this is a new confirmation request.

@schlessera
schlessera marked this pull request as draft November 18, 2026 00:00
@schlessera
schlessera marked this pull request as ready for review November 18, 2026 00:00
@schlessera
schlessera merged commit 969a020 into main Nov 18, 2026
59 of 64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ui-kit The presentational design kit: components, tokens, Storybook, visual baselines. area: ui-react React chat/files/voice components, stores, WebSocket transport. area: ui-sdk Wire protocol, runtime schemas, the server and client SDK surfaces. area: ui-server Hono app factory: turn coordinator, auth, session catalog, routes, cron. contract Touches the integration contract: CONTRACT: commit, contract doc updated in the same commit. type: feat A new capability or a change in user-visible behaviour.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ui-react, ui-server: an honest author for the W4 comment preview, so it can use GitHubComment preview

1 participant