Skip to content

fix(repo): refuse private branches on a partial clone (ADR-0048 q10) - #180

Merged
tonibergholm-codento merged 1 commit into
mainfrom
p37-private
Oct 17, 2026
Merged

tonibergholm-codento merged 1 commit into
mainfrom
p37-private

Conversation

@tonibergholm

@tonibergholm tonibergholm commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

What

Resolves ADR-0048 open question 10, raised in the P37b-i review: private branches on a partial clone.

A probe showed sc branch --private succeeds on a partial clone, and switching to the new branch then fails with a raw NotFound, because opening a private branch flattens and seals whole trees. Following the 37b-i pattern, creating one and switching to one are now refused up front with the explicit partial-clone message (sc backfill --all lifts it). Nothing is touched before the refusal.

Changes

  • branch_private and the private arm of switch_with_identity call refuse_on_partial.
  • Test private_branches_are_refused_on_a_partial_clone covers creation and switching to a manifest tip that reached the clone another way, and asserts HEAD and the working tree are untouched.
  • ADR-0048 open question 10 is marked resolved; the CLAUDE.md refusal list is updated.

Verification

cargo fmt --check, clippy -D warnings, cargo test --workspace --all-targets green locally (619 scl-repo lib tests).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Behavior Changes
    • In partial clones, creating a private branch or switching to one is now refused with a clear unsupported-operation error.
    • These operations remain available after running sc backfill --all.
    • A rejected branch creation does not create a branch reference, and a rejected switch leaves the current branch and working tree unchanged.

…w NotFound

Creating a private branch on a partial clone succeeded, and switching to it
failed with a raw NotFound because opening one flattens and seals whole trees.
Both are now refused with the explicit partial-clone message. Resolves
ADR-0048 open question 10.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T08:23:33.436632Z 3f33f78 PR opened
🔒 Security Review ✅ Completed 2026-10-17T08:23:58.365997Z 3f33f78 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 47ac9778-88b3-452a-b337-27094d94067e
📥 Commits

Reviewing files that changed from the base of the PR and between a30883c and 3f33f78.

📒 Files selected for processing: 5
  • CLAUDE.md
  • crates/repo/src/partial_walks.rs
  • crates/repo/src/private.rs
  • crates/repo/src/repo.rs
  • docs/adr/0048-presence-based-partial-clones.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

📝 Walkthrough

In partial clones, private branch creation and switching now return PartialCloneUnsupported before branch creation or private-switch handling. Tests verify that these operations leave refs, the current branch, and a working-tree file unchanged. The ADR records that sc backfill --all lifts the restriction.

Changes: Private Branches in Partial Clones

Layer / File(s) Summary
Refuse private-branch operations
crates/repo/src/private.rs, crates/repo/src/repo.rs, crates/repo/src/partial_walks.rs, CLAUDE.md, docs/adr/0048-presence-based-partial-clones.md
Private branch creation and switching call refuse_on_partial in partial clones. Tests check the error and confirm that repository state remains unchanged. The documentation records that sc backfill --all lifts the restriction.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 3f33f

Private-branch creation and switching on partial clones are refused without the described repository-state changes. No issue identified here prevents merging after normal checks.

Security architecture risk: ⚪ Minimal · up to 3f33f

The new checks restrict unsupported operations before private-branch writes or checkout occur. Recipient authorization remains intact, and no material security risk introduced or worsened by this change was identified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed enforcement scope is a local repository's private branch refs, object storage and working-tree checkout. The added checks reduce access to those mutation paths rather than granting additional key, filesystem or remote authority.

Trust Boundaries and Controls

  • observed — A present promisor marker triggers refusal, while malformed or unreadable marker content propagates an error rather than permitting the operation. When the marker is absent, the existing recipient-key authorization remains required for private checkout.

Resilience and Maintainability Implications

  • observed — Private materialization still writes files incrementally before moving HEAD, and switching still traverses an existing private HEAD before eligibility refusal. These failure-containment limitations predate the PR. Filtered cloning excludes unavailable private refs, and fetch updates remote-tracking refs rather than local HEAD; neither inspected transition establishes the unresolved legacy incomplete-private-HEAD state.
Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: refusing private branch creation and switching on partial clones. The ADR reference adds relevant context.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files. (2 skipped: 2 …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files. (2 skipped: 2 unsupported.)

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@tonibergholm-codento tonibergholm-codento left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed; checks green on 3f33f78.

@tonibergholm-codento
tonibergholm-codento merged commit e91c4ad into main Oct 17, 2026
8 checks passed
@tonibergholm
tonibergholm deleted the p37-private branch October 17, 2026 08:39
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