Skip to content

feat(provider-review): add authorized Bitbucket review reads - #5745

Closed
iscekic wants to merge 9 commits into
mobile-provider-parity-1d93-s9from
mobile-provider-parity-1d93-s10
Closed

feat(provider-review): add authorized Bitbucket review reads#5745
iscekic wants to merge 9 commits into
mobile-provider-parity-1d93-s9from
mobile-provider-parity-1d93-s10

Conversation

@iscekic

@iscekic iscekic commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

No new behavior — Bitbucket review support is not connected to the app in this change.


Summary

BitbucketReviewAuthorization accepts organization-owned OwnerIntegrationAuthorization only, using the existing broker to check the caller, integration, workspace, destination repository, and review.
BitbucketUuidSchema, BitbucketRepositoryIdentitySchema, BitbucketProviderRepositorySchema, BitbucketPathSchema, and BitbucketUserSchema validate canonical identities and provider data while managed credentials stay on the server.
Workspace tokens identify the workspace instead of the Kilo user; changes to the actor, credential kind, or grants require reconnection during a read.

Files
  • apps/web/src/lib/provider-review/bitbucket-authorization.ts — A (added source), 238 lines (+238/-0). Uses UUID-addressed repository requests and exact organization, integration, workspace, repository-name, review-number, and canonical-link checks. Normalizes provider users, labels workspace principals separately, filters unsafe avatars, and preserves an unknown default branch as null. Rejects control characters, backslashes, empty path segments, and dot segments. Limits paths to 4,096 characters and full repository names to 511. Checks metadata on every response and pins the actor, credential kind, and deduplicated scope set across calls. Reuses the broker's membership, blocked-user, integration, cache-identity, and credential-generation checks.
  • apps/web/src/lib/provider-review/bitbucket-authorization.test.ts — A (added test), 245 lines (+245/-0). Adds the focused authorization suite.

Bitbucket adapters translate provider reads into ReviewInbox, ReviewOverview, ReviewPage, ReviewFile, ReviewFileContext, ReviewThread, ReviewRevision, ReviewCursor, and ReviewCapability.
Revision checks and bounded pagination preserve complete evidence; existing read-only grants remain usable, while missing write grants produce operation-specific recovery.
These additions remain internal: public routes, provider mutations, and mobile rendering do not change, and the inherited fork-source broker contract remains unchanged.

Files
  • apps/web/src/lib/provider-review/bitbucket-read.ts — A (added source), 1,169 lines (+1,169/-0). Adds repository-scoped inboxes with actor labels, an open default, and merged, declined, or superseded filters without implying reviewer assignments. Checks canonical destinations and review identities before reads. Binds cursors to the caller, authorization, actor, credential, grants, resource, query, and revision; rejects foreign links, wrong resources, loops, and inconsistent continuations. Limits provider pages to 50 items, collections to 100 pages and 5,000 items, and responses to the shared byte limit. Resolves abbreviated heads through review commits or validated commits in the authorized repository, including closed reviews after source deletion. Rejects ambiguous or mismatched hashes and preserves typed provider failures instead of reporting false emptiness. Rechecks both heads, source identities, and branch names after composite reads; changed snapshots return conflict. Normalizes descriptions, participants, source and target branches, commit/file counts, and nullable line totals; complete empty collections retain zero counts. Distinguishes absent checks from inaccessible checks, maps provider states, leaves requirement status unknown, and retains only secure detail links. Takes merge-strategy identifiers from destination branch data instead of a fixed GitHub set. Reports pullrequest, pullrequest:write, and repository:write requirements with reconnect or replaceToken recovery. Keeps approvals, reversals, change requests, and comment resolution supported when grants permit, without adding write operations. Marks unknown token participants and OAuth merge permission explicitly; records closed-review, author, prior-participation, and draft restrictions. Describes separate review effects and sets expectedHeadProtection to none, rather than claiming atomic revision protection. Carries the shared request-size limit and leaves unknown body limits, squash settings, automatic-merge state, and merge tasks null. Evaluates enforced approvals, requested changes, open tasks, and passing builds; distinguishes advisory rules and unknown group or branching-model evidence. Restricts source deletion for protected branches, forks, absent branches, default or target branches, unknown defaults, and unavailable restrictions. Applies user exceptions to push and merge restrictions where valid; delete restrictions never use user or group exemptions. Accepts branching-model rules without patterns, requires glob patterns, and treats only * as a wildcard, including across branch separators. Marks automatic-merge scheduling, branch synchronization, and reactions unsupported, with provider evidence and openProvider recovery. Uses immutable topic diffs, preserves old/new paths, renames and copies, and keeps missing bases or line totals unknown. Validates per-file commit links and both hunk lengths, including context, before returning a complete patch. Returns binary, truncated, or unavailable content with metadata and provider links; confirmed empty patches remain available. Validates diff membership and the selected base before context reads, using immutable commits and the inherited fork-source selector through destination authorization. Checks metadata, paths, commit prefixes, byte sizes, and binary content; limits context to 500 lines and does not expand links or subrepositories. Collects complete comment sets before grouping replies and returning 25-thread pages; rejects duplicate, foreign, cyclic, or orphan comments. Preserves thread subjects and resolution, clears deleted authors and bodies, restricts deleted-root resolution, and leaves unprovable positions, diff hunks, and outdatedness null.
  • apps/web/src/lib/provider-review/bitbucket-read.test.ts — A (added test), 1,506 lines (+1,506/-0). Adds provider fixtures and regression coverage for closed-review revisions, patch completeness, and source deletion protection.

Tests: 2 files added — bitbucket-authorization.test.ts and bitbucket-read.test.ts; 1,751 added lines and no removed lines.
Generated: 0 files changed.


Visual Changes

Visual Changes: N/A

Verification

  • Manual and live end-to-end (E2E) verification did not run because public integration and mobile rendering belong to later section levels.
  • Cumulative runtime verification awaits the remaining section levels; no live provider behavior is verified here.

Reviewer Notes

Human steps

  • No human steps are required before merge or after merge.
  • This change requires no new environment value, secret, migration, flag, deployment order, or cache reset.

Automated evidence

  • The supplied evidence reports 201 passing tests across two Bitbucket suites, including 60 repair cases.
  • The repair evidence records failing-before cases and passing scoped lint, formatting, and whitespace checks.
  • Repository-wide tests, project type checks, builds, and live provider checks did not run for this level.
  • The dispatcher owns standard continuous integration (CI) and live provider verification before human-ready; these checks are not human tasks.

Scope and inventory

  • Repository: Kilo-Org/cloud.
  • Worktree: /Users/igor/Projects/.worktrees/mobile-provider-parity-1d93; branch: mobile-provider-parity-1d93.
  • Review range: mobile-provider-parity-1d93-s9...mobile-provider-parity-1d93-s10.
  • Inventory: 4 added files; 2 source files, 2 test files, and 0 generated files; +3,158/-0 lines.

Notes

E2E: bot-e2e — cumulative runtime verification is pending until the remaining section levels land.

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 ← this PR
  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
  13. mobile-provider-parity-1d93-s13feat(provider-review): expose the neutral review facade #5763 (tip)

@kilo-code-bot

kilo-code-bot Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Explicit ReviewPage<T> annotation on Bitbucket page collection; no behavior change and no new issues.

Files Reviewed (1 file)
  • apps/web/src/lib/provider-review/bitbucket-read.ts
Previous Review Summaries (2 snapshots, latest commit b50cc1d)

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

Previous review (commit b50cc1d)

Status: No Issues Found | Recommendation: Merge

Executive Summary

Implied pullrequest from pullrequest:write is applied only to comment-class grants; write-grant checks stay exact-match and fail-closed.

Files Reviewed (2 files)
  • apps/web/src/lib/provider-review/bitbucket-read.ts
  • apps/web/src/lib/provider-review/bitbucket-read.test.ts

Previous review (commit 8e50df8)

Status: No Issues Found | Recommendation: Merge

Executive Summary

Reviewed the new Bitbucket authorization and read adapters (4 files); identity pinning, pagination, fork-source reads, and capability mapping look consistent with the intended fail-closed contract.

Files Reviewed (4 files)
  • apps/web/src/lib/provider-review/bitbucket-authorization.ts
  • apps/web/src/lib/provider-review/bitbucket-authorization.test.ts
  • apps/web/src/lib/provider-review/bitbucket-read.ts
  • apps/web/src/lib/provider-review/bitbucket-read.test.ts

Reviewed by grok-4.6 · Input: 42.7K · Output: 7.9K · Cached: 373.6K

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

@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