Skip to content

feat(repo): sc rewrap --rotate re-seals protected paths under fresh keys (ADR-0051) - #196

Merged
tonibergholm-codento merged 4 commits into
mainfrom
rotate-paths
Oct 19, 2026
Merged

tonibergholm-codento merged 4 commits into
mainfrom
rotate-paths

Conversation

@tonibergholm

@tonibergholm tonibergholm commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Problem

sc revoke is standing-only and sc rewrap only replaces wrap lists, so a recipient revoked earlier who still holds an old wrap and DEK keeps opening the tip's ciphertext. Secrets have sc secret rotate; protected paths had no equivalent. ADR-0043 recorded rotate-for-paths as an unlocked follow-on (randomized DEKs are independent of the plaintext).

Change

sc rewrap --rotate (Repo::rewrap_with(.., rotate); rewrap() is unchanged) re-seals every protected blob at the tip under a fresh DEK and nonce, to the rule's granted set plus escrow. It reuses the existing convergent-upgrade branch (unwrap, decrypt, encrypt_path_randomized, retarget the entry, drop the old ciphertext's wrap entry once unreferenced, record the working file in the stat cache). One commit, one oplog record, skip-and-report for blobs the identity cannot open (left byte-for-byte as they were), and all existing guards (private branch, partial clone, in-progress merge/pick/rebase). New blobs_rotated count, separate from the convergent blobs_resealed.

Rotation is not erasure: history keeps the old ciphertext and wraps. ADR-0051 records this; ROADMAP, ARCHITECTURE, ADR-0043, CLAUDE.md and the CLI reference are updated.

Verification

  • rotate_makes_the_tip_unreadable_with_a_revoked_recipients_old_dek: a plain rewrap leaves a revoked recipient's old DEK working; dry-run commits nothing; rotate changes the ciphertext id, the old DEK no longer opens it, alice still reads the plaintext, the old wraps are gone, status is clean, a second rotate is another fresh seal, and undo restores.
  • rotate_skips_a_path_the_identity_cannot_open_and_rotates_the_rest.
  • demo/run_rewrap_demo.sh step 7 proves it through the CLI.
  • cargo fmt, cargo clippy --workspace --all-targets -D warnings, cargo test --workspace pass.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added sc rewrap --rotate to reseal protected files at the latest revision under fresh keys, helping prevent holders of old keys from opening the rotated files.
    • Rotation reports separately from other resealing, and files that cannot be opened are skipped and reported; other files can still be processed.
  • Documentation
    • Clarified the difference between rotation and ordinary rewrapping. Earlier snapshots remain unchanged, so rotation does not remove access to historical versions.

…eys (ADR-0051)

A plain rewrap drops a revoked recipient's wrap but keeps the DEK, so a
recipient with an old wrap still opens the tip. --rotate reuses the
convergent-upgrade branch to decrypt each protected blob and re-seal it under
a fresh DEK to the rule's granted set plus escrow: one commit, one oplog
record, skip-and-report, new ciphertext ids. History keeps the old
ciphertext (rotation is not erasure).

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

chatgpt-codex-connector Bot commented Oct 19, 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-19T10:01:58.549757Z 8eef476 New commits
🔒 Security Review ✅ Completed 2026-10-19T10:04:10.101376Z 8eef476 New commits
ℹ️ 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.

@tonibergholm

Copy link
Copy Markdown
Member Author

Independent Codex Sol (gpt-6.1-sol, read-only) review of the diff: no new security or data-integrity bugs. It checked old-ciphertext/wrap leakage, shared ciphertext ids rotating independently with the right DEK, tree rebuild, stat-cache recording, dry-run side effects, empty grant sets and the upgraded_from cleanup. One pre-existing, medium note, not changed here: commit_snapshot moves the ref before the oplog append, so an oplog write failure leaves the commit without an undo record. That ordering is shared by every ref-moving command in this codebase and is documented as its crash discipline; it is not specific to rotation.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 78919e8e6a

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/cli/src/main.rs Resolved
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9328135a75

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ARCHITECTURE.md Resolved
…p --rotate

ADR-0051 carries the new decision. The threat model and ARCHITECTURE said a
plain sc rewrap is the cryptographic cutover, which leaves a revoked holder's
key working; they now name --rotate.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@tonibergholm
tonibergholm deleted the rotate-paths branch October 19, 2026 09:58
@tonibergholm
tonibergholm restored the rotate-paths branch October 19, 2026 09:58
@tonibergholm tonibergholm reopened this Oct 19, 2026
@coderabbitai

coderabbitai Bot commented Oct 19, 2026

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b83d5a6f-1c54-40bc-8159-f3c93b945fc1
📥 Commits

Reviewing files that changed from the base of the PR and between c4a520a and 8eef476.

📒 Files selected for processing: 10
  • .claude/skills/sc-cli-reference/SKILL.md
  • ARCHITECTURE.md
  • CLAUDE.md
  • ROADMAP.md
  • crates/cli/src/main.rs
  • crates/repo/src/rewrap.rs
  • demo/run_rewrap_demo.sh
  • docs/THREAT-MODEL.md
  • docs/adr/0051-rotate-protected-paths.md
  • docs/adr/README.md
+---------------------------------------------------------------------------------+
| CodeRabbit is a psyop to make you think your code is being reviewed by a human. |
+---------------------------------------------------------------------------------+
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ 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 merged commit c44d426 into main Oct 19, 2026
7 of 8 checks passed
@tonibergholm
tonibergholm deleted the rotate-paths branch October 19, 2026 10:08
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