Skip to content

feat(cloud-agent): commit as yourself instead of the Kilo bot#3638

Open
eshurakov wants to merge 4 commits into
mainfrom
mercurial-script
Open

feat(cloud-agent): commit as yourself instead of the Kilo bot#3638
eshurakov wants to merge 4 commits into
mainfrom
mercurial-script

Conversation

@eshurakov
Copy link
Copy Markdown
Contributor

@eshurakov eshurakov commented Jun 1, 2026

Summary

  • Add GitHub user-to-server authorization through the existing Kilo GitHub App so Cloud Agent sessions can perform Git transport and GitHub API actions as the signed-in user instead of the installation bot.
  • Keep persisted GitHub user credentials in git-token-service: Web encrypts new authorizations with a public-key envelope, while the Worker owns private-key decryption, refresh, disconnect, revocation, and serialized token mutation.

Verification

  • Tested the GitHub personal-authorization flow locally through the web UI across different scenarios.
  • Verified the Cloud Agent identity setup tip locally in the browser and refined its placement, centering, and dismissal behavior.
  • Verified local connect and disconnect behavior against the GitHub user-authorization flow.

Visual Changes

Tip when you pick a repo and personal account is not connected

Screenshot 2026-06-01 at 22 29 05

Integration

Screenshot 2026-06-01 at 22 29 16

Bot is a co-author

Screenshot 2026-06-01 at 22 02 29

Comment thread services/cloud-agent-next/src/workspace.ts Outdated
Comment thread services/git-token-service/src/github-user-authorization-service.ts
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented Jun 1, 2026

Code Review Summary

Status: 1 Issue Remaining (Acknowledged, Deferred) | Recommendation: Merge

Executive Summary

The new commit (9b22778af) adds correct handling for stale/terminal refresh tokens during disconnect, with full test coverage. No new issues found.

Changes in latest commit (incremental review)

services/git-token-service/src/github-user-authorization-service.ts

  • New DisconnectRefreshResult union type (AuthorizationRow | 'terminal_refresh_token' | null) cleanly models the three outcomes.
  • refreshAuthorizationForDisconnect now returns 'terminal_refresh_token' when the refresh token is already expired (by timestamp) or GitHub rejects it with { error: 'bad_refresh_token' }.
  • The caller (disconnectUserAuthorization) correctly deletes the row when both access and refresh tokens are definitively expired/invalid, and correctly throws (preserving the row) when the access token is still valid but unrevokable.
  • JSON body is parsed once before the response.ok guard — intentional and correct, as GitHub's token endpoint returns 200 with error fields.

services/git-token-service/src/github-user-authorization-service.test.ts

  • Four new tests covering: both tokens expired (skip fetch, delete), access expired + GitHub rejects refresh token (delete), unexpired access + expired refresh (retain row, throw), and 422-revocation followed by transient refresh failure (retain row, throw). All scenarios match the updated logic.
Carried-forward issue (unchanged file, deferred by author)
File Line Issue
services/git-token-service/src/github-user-authorization-service.ts 448 SUGGESTION (deferred): refreshAuthorizationForDisconnect and refreshAuthorization remain near-identical — only difference is error vs null on DB update conflict. A throwOnConflict flag or shared helper would reduce divergence risk. PR author has acknowledged and deferred to a follow-up.
Files Reviewed (59 files)
  • services/git-token-service/src/github-user-authorization-service.ts — 1 suggestion (deferred) ✓
  • services/git-token-service/src/github-user-authorization-service.test.ts — New tests verified ✓
  • services/cloud-agent-next/src/workspace.ts — Shell injection fix verified ✓
  • services/cloud-agent-next/src/workspace.test.ts — Shell injection tests verified ✓
  • All other files from previous review — no issues ✓

Reviewed by claude-4.6-sonnet-20260217 · 528,871 tokens

Review guidance: REVIEW.md from base branch main

Allow eligible Cloud Agent work to use connected GitHub identities while retaining installation fallback and bot co-authoring. Keep persisted user credentials in Worker-owned keyed envelopes and route disconnect revocation through the established internal API boundary.

Surface contextual identity setup guidance in Cloud Agent and identify revocation requests so disconnect succeeds against GitHub.
eshurakov added 2 commits June 1, 2026 23:04
Removed commented lines for GitHub user-attributed Cloud Agent actions.
@eshurakov eshurakov changed the title feat(github): add user-attributed cloud agent actions feat(cloud-agent): commit as yourself instead of the Kilo bot Jun 2, 2026
Copy link
Copy Markdown
Contributor

@jeanduplessis jeanduplessis left a comment

Choose a reason for hiding this comment

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

Reviewed the final combined diff. Solid security posture overall: the webhook signature is verified before the new github_app_authorization revocation branch, timingSafeEqual guards the length/empty-secret bypass, the AAD-bound RSA-AES envelope matches exactly between Web encrypt and Worker decrypt/refresh, both unique indexes back the upsert, the co-author hook + auto-commit trailer are idempotent, and GDPR soft-delete now covers user_github_app_tokens with a test.

One concrete edge-case bug (inline): disconnecting an authorization with expired/dead tokens returns 502 permanently and never removes the local row, leaving the user unable to disconnect or reconnect.

Two non-blocking suggestions:

  • refreshAuthorizationForDisconnect duplicates ~50 lines of refreshAuthorization (already acknowledged/deferred — fine to leave).
  • sanitizeGitOutput is duplicated across the src and wrapper bundles and can silently drift if a new credential-username scheme is added to only one regex; consider sharing it.

Comment thread services/git-token-service/src/github-user-authorization-service.ts
@eshurakov eshurakov requested a review from jeanduplessis June 2, 2026 08:43
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