Skip to content

feat(provider-review): add Bitbucket review actions and recovery - #5756

Closed
iscekic wants to merge 9 commits into
mobile-provider-parity-1d93-s11from
mobile-provider-parity-1d93-s12
Closed

feat(provider-review): add Bitbucket review actions and recovery#5756
iscekic wants to merge 9 commits into
mobile-provider-parity-1d93-s11from
mobile-provider-parity-1d93-s12

Conversation

@iscekic

@iscekic iscekic commented Aug 30, 2026

Copy link
Copy Markdown
Contributor
  • Bitbucket settings explain write permissions while existing connections keep read access.
  • Managers can reconnect Bitbucket without losing the selected workspace; errors explain recovery steps and preserve the existing connection.
  • Screen readers can read token instructions, and replacement dialogs scroll on small screens.

Summary

BitbucketMergeEvidenceSchema, BitbucketMergeEvidence, and PersistBitbucketMergeEvidence bind recovery to durable, server-observed source/destination identities, excluding client claims.
Evidence counts toward storage limits; retries clear stale evidence.
Accepted or confirmed merges without valid evidence return merge_identity_unavailable; unknown effects block blind retries.

Files
  • apps/web/src/lib/provider-review/operation.ts — M, +52/−6; persists evidence before dispatch and reconciles uncertain merges.
  • packages/app-shared/src/provider-review/contracts.ts — M, +15/−0; validates complete repository, workspace, and branch identities.

runBitbucketReviewOperation and BitbucketReviewOperationRequest support comments/replies, thread resolution/reopening, approval/change-request toggles, batches, and merges internally; no public facade or mobile controls expose them.
Capability, identity, revision, position, target, and payload checks detect drift, not atomic expected-head protection; non-merge receipts remain unresolved.
Merge recovery reads provider/task outcomes without resubmission; batches retain child results and stop at unknown effects, while deletion uses observation without another delete.

Files
  • apps/web/src/lib/provider-review/bitbucket-write.ts — A, +831/−0; handles fork revisions, merge strategies, and status-only legacy children.

BitbucketOAuthRecoverySchema and BitbucketOAuthRecovery add optional signed bitbucketRecovery to createOAuthState, VerifiedOAuthState, and StoreBitbucketIntegrationInput; legacy callers remain valid.
Bitbucket connect/callback routes validate reconnectIntegrationId through getBitbucketOAuthRecovery; atomic credential replacement preserves the integration, workspace, and cache.
BitbucketIntegrationRecoveryError rejects stale targets, unauthorized recovery, unavailable workspaces, and missing write grants; ordinary connections still reject replacement.

Files
  • apps/web/src/lib/integrations/oauth-state.ts — M, +44/−5; signs strict, expiring recovery context.
  • apps/web/src/lib/integrations/oauth/platforms/bitbucket-connect.ts — M, +24/−6; authenticates owner-scoped reconnect targets.
  • apps/web/src/lib/integrations/oauth/platforms/bitbucket-callback.ts — M, +37/−4; rejects unsigned selectors; skips recovery cache priming.
  • apps/web/src/lib/integrations/platforms/bitbucket/credentials.ts — M, +173/−30; locks encrypted replacements, versions credentials, rejects blocked personal authorizers.

getBitbucketReviewGrantStatus reports readReady, writeReady, and recoveryAction; optional reviewPermissions cannot establish write access when absent.
OAuth requests pullrequest:write, normalizes legacy/implied grants, preserves old read grants, and retains write grants during refresh.
BitbucketOAuthScopeError identifies missing read scopes; incomplete write grants require reconnect or replace_token.

Files
  • packages/worker-utils/src/bitbucket-workspace-access-token.ts — M, +20/−0; computes grant readiness and recovery actions.
  • apps/web/src/lib/integrations/platforms/bitbucket/adapter.ts — M, +17/−4; requests write grants with typed scope failures.
  • services/git-token-service/src/bitbucket-authorization-service.ts — M, +6/−0; preserves normalized grants through credential refresh.
  • apps/web/src/lib/integrations/platforms/bitbucket/workspace-access-token-repository-cache.ts — M, +15/−0; exposes optional permissions, null for unusable connections.

BitbucketReviewPermissions and BitbucketTokenPermissions share accessible guidance; connected managers gain OAuth reconnect controls without exposing review actions.
Recovery messages distinguish connection_changed, workspace_unavailable, and missing_scopes; non-managers retain read-only controls.

Files
  • apps/web/src/components/integrations/BitbucketConnectSetup.tsx — M, +34/−10; requires Pull request Write and links token guidance.
  • apps/web/src/components/integrations/BitbucketConnectedManagement.tsx — M, +2/−0; shows guidance throughout connected recovery states.
  • apps/web/src/components/integrations/BitbucketIntegrationControls.tsx — M, +21/−2; adds scoped reconnect links and scrollable replacement guidance.
  • apps/web/src/components/integrations/BitbucketIntegrationDetails.tsx — M, +6/−0; explains recovery errors and retained connections.

Tests: 13 files, +3,558/−41, cover recovery, grants, evidence, and uncertain writes: apps/web/src/app/api/integrations/bitbucket/callback/route.test.ts (M,+212/−1); apps/web/src/app/api/integrations/bitbucket/connect/route.test.ts (M,+123/−17); apps/web/src/components/integrations/BitbucketConnectSetup.test.ts (A,+98/−0); apps/web/src/components/integrations/BitbucketIntegrationDetails.test.ts (M,+256/−1); apps/web/src/lib/integrations/oauth-state.test.ts (M,+94/−1); apps/web/src/lib/integrations/platforms/bitbucket/adapter.test.ts (M,+39/−5); apps/web/src/lib/integrations/platforms/bitbucket/credentials-reconnect.test.ts (A,+470/−0); apps/web/src/lib/integrations/platforms/bitbucket/credentials.test.ts (M,+230/−11); apps/web/src/lib/provider-review/bitbucket-write.test.ts (A,+1,316/−0); apps/web/src/lib/provider-review/operation.test.ts (M,+461/−2); packages/app-shared/src/provider-review/contracts.test.ts (M,+56/−0); packages/worker-utils/src/bitbucket-workspace-access-token.test.ts (M,+35/−0); services/git-token-service/src/bitbucket-authorization-service.test.ts (M,+168/−3).
Generated: 0 files changed.


Verification

Manual runtime checks have not run because verification remains pending in the bot-e2e phase.

Visual Changes

Visual Changes: N/A

Reviewer Notes

Human steps

  • Before merge: Enable Pull request Write on the deployed Bitbucket OAuth consumer.
  • Before merge: Deploy the credential service before clients use pinned provider launch and review paths.

Automated evidence

  • Supplied checks passed: 175 web tests and six scoped checks; separately, 162 web tests, 68 shared contract tests, and nine scoped checks.
  • These results establish neither runtime nor continuous integration (CI) completion.

Inventory

  • Kilo-Org/cloud worktree: /Users/igor/Projects/.worktrees/mobile-provider-parity-1d93.
  • Range: mobile-provider-parity-1d93-s11...mobile-provider-parity-1d93-s12.
  • Audited: 15 source files, 13 test files; 4 added, 24 modified; +4,855/−108 lines. A means added; M means modified.

Notes

Runtime verification is pending in the bot-e2e phase; the dispatcher retains that obligation.
Standard CI must execute the database-backed Bitbucket credential and repository-cache suites before completion.

Stacked PRs — merge bottom to top. Each level shows only its own diff.

Runtime verification (E2E, user advocacy, simplify) runs on the tip PR over every level.
Every level keeps its own checks, its own bot review, and its own threads; each one is answered on its own PR.
Each level is its own deliverable: it builds and passes its own checks alone.
A finding on a level is repaired on that level, then carried upward with stack.sh forward.

  1. mobile-provider-parity-1d93-s1feat(provider-review): add shared identity and stack checks #5663
  2. mobile-provider-parity-1d93-s2feat(provider-review): define review contracts and vocabulary #5665
  3. mobile-provider-parity-1d93-s3feat(provider-review): add safe provider SDK boundaries #5689
  4. mobile-provider-parity-1d93-s4feat(git-token): authorize exact provider review resources #5692
  5. mobile-provider-parity-1d93-s5feat(cloud-agent): preserve provider identity through checkout #5700
  6. mobile-provider-parity-1d93-s6feat(provider-review): expose exact repositories and branches #5705
  7. mobile-provider-parity-1d93-s7feat(mobile): preserve provider launch and recent identity #5711
  8. mobile-provider-parity-1d93-s8feat(mobile): select exact provider repositories and branches #5729
  9. mobile-provider-parity-1d93-s9feat(provider-review): add authorized GitLab review reads #5738
  10. mobile-provider-parity-1d93-s10feat(provider-review): add authorized Bitbucket review reads #5745
  11. mobile-provider-parity-1d93-s11feat(provider-review): add reconciled GitLab review actions #5748
  12. mobile-provider-parity-1d93-s12feat(provider-review): add Bitbucket review actions and recovery #5756 ← this PR
  13. mobile-provider-parity-1d93-s13feat(provider-review): expose the neutral review facade #5763 (tip)

const expected = evidence[side];
if (
endpoint.repository?.uuid !== expected.repositoryId ||
endpoint.repository.workspace?.uuid !== expected.workspaceUuid ||

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.

CRITICAL: Async merge confirmation treats omitted Bitbucket workspace as identity drift

snapshot() is the only call that requests +source.repository.workspace,+destination.repository.workspace. Bitbucket condensed PR identities omit nested workspace, and merge / mergeTask cannot pass a fields query.

merged() still requires workspace?.uuid === expected.workspaceUuid on both the merge/task body and the snapshot. A 200 merge can recover on a later snapshot-only reconcile, but a 202 SUCCESS path always passes task.merge_result into merged(), so a successful async merge hits conflict() forever and never confirms.

Skip the workspace comparison when the provider body omits workspace, or confirm identity from the snapshot (which requested the field) instead of treating condensed merge/task payloads as drift.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@kilo-code-bot

kilo-code-bot Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Fix these issues in Kilo Cloud

Overview

Severity Count
CRITICAL 1
WARNING 0
SUGGESTION 0
Issue Details (click to expand)

CRITICAL

File Line Issue
apps/web/src/lib/provider-review/bitbucket-write.ts 446 Async merge confirmation treats omitted Bitbucket workspace as identity drift
Files Reviewed (1 file)
  • apps/web/src/lib/provider-review/bitbucket-write.ts - 1 issue
Previous Review Summary (commit 99d738d)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 99d738d)

Status: 1 Issue Found | Recommendation: Address before merge

Fix these issues in Kilo Cloud

Overview

Severity Count
CRITICAL 1
WARNING 0
SUGGESTION 0
Issue Details (click to expand)

CRITICAL

File Line Issue
apps/web/src/lib/provider-review/bitbucket-write.ts 446 Async merge confirmation treats omitted Bitbucket workspace as identity drift
Files Reviewed (28 files)
  • apps/web/src/app/api/integrations/bitbucket/callback/route.test.ts
  • apps/web/src/app/api/integrations/bitbucket/connect/route.test.ts
  • apps/web/src/components/integrations/BitbucketConnectSetup.test.ts
  • apps/web/src/components/integrations/BitbucketConnectSetup.tsx
  • apps/web/src/components/integrations/BitbucketConnectedManagement.tsx
  • apps/web/src/components/integrations/BitbucketIntegrationControls.tsx
  • apps/web/src/components/integrations/BitbucketIntegrationDetails.test.ts
  • apps/web/src/components/integrations/BitbucketIntegrationDetails.tsx
  • apps/web/src/lib/integrations/oauth-state.test.ts
  • apps/web/src/lib/integrations/oauth-state.ts
  • apps/web/src/lib/integrations/oauth/platforms/bitbucket-callback.ts
  • apps/web/src/lib/integrations/oauth/platforms/bitbucket-connect.ts
  • apps/web/src/lib/integrations/platforms/bitbucket/adapter.test.ts
  • apps/web/src/lib/integrations/platforms/bitbucket/adapter.ts
  • apps/web/src/lib/integrations/platforms/bitbucket/credentials-reconnect.test.ts
  • apps/web/src/lib/integrations/platforms/bitbucket/credentials.test.ts
  • apps/web/src/lib/integrations/platforms/bitbucket/credentials.ts
  • apps/web/src/lib/integrations/platforms/bitbucket/workspace-access-token-repository-cache.ts
  • apps/web/src/lib/provider-review/bitbucket-write.test.ts - 1 issue
  • apps/web/src/lib/provider-review/bitbucket-write.ts - 1 issue
  • apps/web/src/lib/provider-review/operation.test.ts
  • apps/web/src/lib/provider-review/operation.ts
  • packages/app-shared/src/provider-review/contracts.test.ts
  • packages/app-shared/src/provider-review/contracts.ts
  • packages/worker-utils/src/bitbucket-workspace-access-token.test.ts
  • packages/worker-utils/src/bitbucket-workspace-access-token.ts
  • services/git-token-service/src/bitbucket-authorization-service.test.ts
  • services/git-token-service/src/bitbucket-authorization-service.ts

Reviewed by grok-4.6 · Input: 113.6K · Output: 10K · Cached: 208.6K

Review guidance: REVIEW.md from base branch mobile-provider-parity-1d93-s11

@iscekic

iscekic commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Closing: the owner stopped this workflow section. The branch is retained.

@iscekic iscekic closed this Aug 31, 2026
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.

1 participant