Skip to content

feat(web): read private repos and manage their members - #51

Merged
PastaPastaPasta merged 24 commits into
masterfrom
feat/private-repos-web-read
Sep 27, 2026
Merged

PastaPastaPasta merged 24 commits into
masterfrom
feat/private-repos-web-read

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

This is the web half of private repositories, part 1: reads and members. It follows docs/security/private-repos.md and matches the CLI (dg).

  • Vault encryption key. Import has an opt-in "Enable private repos" checkbox. Settings → Keys → Enable private repos adds the key from an identity file or a recovery phrase, or registers a new one (one master-key signature, cost shown first). The key is sealed in the vault under its own HKDF subkey, never in plaintext. A renewal that loses it says so.

  • Private sessions (lib/repo/private-session.ts). Each session:

    • unwraps the reader's repoKeys through the SDK's encryptedFor;
    • resolves epochs (§5.3–§5.6: anchors, the §5.4 reader rule, the chain walk, contiguity, burned epochs);
    • opens content through open_content (§8.1), including the late-content rule (§8.2).

    Sessions are per tab and end when the vault locks, the identity or network changes, or the key changes. Write flows use their own uncached sessions.

  • Decrypted reads. Refs (the full reflog through the gate, keyed by ref-name hash), tree, blob and commit through sealed packs (readPackRange with a header cache; whole artifacts are checked against packHash), issues, PRs, comments and reviews. Decrypted paths, refs and oids never reach the URL: private route params become per-tab tokens (~ + 16 hex).

  • Lock chip, alerts and the sealed state. Outsiders see only the public metadata. Members without a key are told how to add one.

  • Members panel. Add a member (their usable ENCRYPTION key is checked first, then the membership document and a wrap). Remove a member (the verbatim warning, then delete → rotate, cost shown). Maintainer removal re-anchors their epochs first. Repair (§5.6) is offered from the banner.

  • Release assets are refused on private repos, as dg does. Sealed config and wrap writes assert no plaintext.

Part 2 (feat/private-repos-web-writes) adds the /new visibility toggle, sealed browser writes and the Playwright spec.

Merge order. The CLI follow-up (#64: contiguous and burned epochs, the stated-anchor rule, skip keys, safe maintainer changes) merged first. This PR is rebased onto it and takes its lib/private/{epoch,tlv,doc}.ts and conformance harness as is; all 181 private vectors pass here.

Traceability

Every UI element and rule traces to the spec. Nothing here is invented.

Element Source
Settings → Keys → "Enable private repos"; import checkbox private-repos.md §5.2, ux-dx-spec §9
Blast-radius text next to the key private-repos.md §5.2 (custody, blast radius)
"bob has no encryption key yet. Send them this: …" (Add stays disabled) ux-dx-spec §9 "Add member"
Add member = membership doc + repoKey wrap, cost shown private-repos.md §5.5, §9; ux-dx-spec §9
Remove warning, verbatim ux-dx-spec §9 "Remove member"
Delete → wraps (self first) → anchor → confirm, cost members + 1 private-repos.md §5.5
"key epoch 3 · rotated 2 d ago by alice" private-repos.md §9, ux-dx-spec §9
Lock chip "Private · decrypted with your key (epoch n)" ux-dx-spec §9 "Reading"
KeyMismatch / ChainBroken / "n documents under an unrecognised epoch" alerts private-repos.md §9
EpochGap alert; contiguity; prevEpoch = e − 1 private-repos.md §5.3 (CLI follow-up)
Burned epochs: chain-only, not writable, late content, repair rotates, "closed by X" private-repos.md §5.3, §5.6, §8.2 (CLI follow-up)
Repair banner "rotating the repo key: bob still had the current key" + Repair button private-repos.md §5.6, §9
Maintainer removal: re-anchor (same key, whole chain link: prevEpoch, prevEpochKey, skipEpochKey, burned), keep-wrap every epoch held only through the leaver, drop unreadable top epochs only if no staying maintainer holds them (the leaver's own wraps don't count), refuse if the surviving epoch is unreadable, name who takes over private-repos.md §5.3 (CLI follow-up)
Adding a maintainer must not change any anchor, and never with a config of theirs above the current epoch ("add them as a writer, or use a new identity") private-repos.md §5.3 (CLI follow-up)
A config counts only after the epoch below it was stated (the stated-anchor rule) private-repos.md §5.3 (#64)
Burned anchors carry no key below; the next anchor carries skipEpochKey; burned keys are handed to every remaining member first so any maintainer can finish a burn private-repos.md §5.3 (#64)
writeEpoch is null while a non-member holds the current key private-repos.md §5.6 (#64)
Removing your own maintainer role while you anchor an epoch is refused ("Keep the role") CLI parity (reanchor_before_removal)
Private repos never use the plain grant/revoke writers (refused in lib/repo/writes.ts) coordinator review (H2)
Hidden undecryptable/plaintext docs; maintainers see counts ux-dx-spec §9, private-repos.md §8.1
Late content (GRACE_BLOCKS 240) private-repos.md §8.2
Suspect packs ("uploaded under an old key") private-repos.md §8.2, §9
Error codes E306–E310, E509, E510 private-repos.md §13 / CLI errors.md
Release assets refused on private repos parity with dg (CLI security review LOW-2)
Decrypted names kept out of URLs private-repos.md §7 (metadata that stays visible)

Reviews

The security reviews went through several rounds, and each HIGH or MEDIUM fix has a failing-first unit test.

  • Rotation retries and resume. A retry reads its standing self-wrap back and reuses its key. Every signed write's intent carries a tag of its key. Standing wraps are verified instead of trusted.
  • Removals and lagging reads.
    • Every read in a removal's rotation drops the deleted membership.
    • The member list is re-read and must agree before any key goes out.
    • This signer's wraps are read back before the anchor, and none may be outside the remaining members.
  • Contiguity and burned epochs (coordinator decision): a rotation whose pending key reached a removed member anchors that epoch burned and rotates on.
  • Burn and contiguity attack round.
    • Any maintainer can finish a burn.
    • A burn confirms its n+1 anchor before building n+2.
    • A re-anchor keeps the burned flag.
    • A fallback anchor must match the key, flag and chain pair.
    • A malicious maintainer can't make themselves unremovable: their unreadable top epochs vanish, but only if no staying maintainer holds them.
    • Re-granting a maintainer whose old configs would move an anchor, or who has a config above the current epoch, is refused.
    • Step 4 refuses a later anchor that predates ours.
    • A removal whose surviving epoch the remover can't read is refused before the delete.
    • Adding a member while the current epoch is burned writes nothing.
  • Later rounds (after feat(private): contiguous key epochs, burned epochs and safe maintainer changes #64's design changes).
    • The rotation loop mirrors forge-core keyring::rotate: a removal burns any resumed or adopted epoch; an unusable standing wrap burns instead of sticking; a burn resumes n+2 from its pending self-wrap.
    • A maintainer removal predicts the fallback anchors and refuses before writing; lost, pre-empted and mismatched rotations are reported, never swallowed.
    • An adopted self-wrap to a key this browser lacks is refused before anything else is paid.
    • Raw keys are wiped on every path, including a skip-key refusal; a decrypted config never exposes prevEpochKey or skipEpochKey.
  • Correctness reviews.
    • Session lifecycle: closed sessions are never served, write sessions are uncached, caches are purged when a session ends.
    • Sealed URLs.
    • Import wipes key material on every path.
    • Registering refuses when the identity already has a key the phrase can't derive.
  • Simplifier. Shared helpers, dead exports removed, stale comments fixed.

Known limitations

  • Residual lag (fix: make the Testnet Nightly green and trustworthy #10, accepted for v1). The SDK can't pin one DAPI node per request (checked against evo-sdk 4.2.0-beta.4). A removal's reads may come from nodes at different heights. Mitigations:

    • the membership re-read before any key goes out;
    • the drop list;
    • the read-back of this signer's wraps;
    • several fresh reads before a maintainer removal;
    • the repair check after every rotation.

    A small window remains in which a lagging node can hide a just-posted document.

  • Comments and reviews on private repos are read-only in this PR ("aren't supported yet" note). Browser writes come in part 2.

  • A burn costs its author one config and costs the finisher members + 1 writes. The banner names who closed the epoch and points the owner at removal.

Test plan

  • pnpm lint, pnpm exec tsc --noEmit, pnpm build (deleted .next/out afterwards).

  • pnpm test: 1388 pass on master c47a954, with all 181 private conformance vectors.

  • e2e/v2-private-members.spec.ts (moutai, E2E_WRITE=1): a private repo's settings never offer the plain Add or Remove (2/2).

  • Live on moutai (FORGE_LIVE=1): lib/private/private.live.test.ts creates a private repo with every §13 document type, and lib/repo/private-session.live.test.ts reads it back as a member and as an outsider.

  • Browser QA on moutai (Playwright, real signing, local static build), screenshots in /tmp/claude-501/pr3-qa/:

    1. Import with "Enable private repos" → the key stored in Settings → Keys.
    2. Member browse: home, branches, issues, issue, PR, settings. The chip shows epoch 0, and the compose note shows.
    3. Outsider sees the sealed page, and no decrypted string is in the DOM.
    4. Owner adds CONTRIB as writer (cost ~0.00089 DASH shown first) → CONTRIB reads the repo, and the chip shows the epoch.
    5. Owner removes CONTRIB. The dialog shows the verbatim warning and cost ~0.00084 DASH; the steps are "Waiting for the member list… · Key for epoch 1 handed to 9r27… · Waiting for the anchor of epoch 1… · Key epoch 1 is in effect". The panel then reads "key epoch 1 · rotated just now by 9r27…", with no repair pending.
    6. Removed CONTRIB sees "Private: contents are encrypted for members. You're not one."
    7. A writer document without a wrap (as a crash between the two writes leaves it) → the owner's banner says "1 member has no copy of the current key yet" → Repair → CONTRIB reads under epoch 1.

    The smoke repo's storage URI is example.invalid, so its Verification card reads "Failed" on the storage row; refs are still proven. That comes from the fixture, not from this change.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 35 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 3a603165-d395-48f4-9d36-ade1d2832a35

📥 Commits

Reviewing files that changed from the base of the PR and between c47a954 and 409ea9f.

📒 Files selected for processing (54)
  • forge-web/app/repo/settings/client.tsx
  • forge-web/app/settings/page.tsx
  • forge-web/components/encryption-key-panel.tsx
  • forge-web/components/login-modal.tsx
  • forge-web/components/repo/hidden-note.tsx
  • forge-web/components/repo/issue-content.tsx
  • forge-web/components/repo/issues-content.tsx
  • forge-web/components/repo/new-release.tsx
  • forge-web/components/repo/private-banner.tsx
  • forge-web/components/repo/private-members.tsx
  • forge-web/components/repo/private-repo-state.tsx
  • forge-web/components/repo/pull-content.tsx
  • forge-web/components/repo/pull-diff.tsx
  • forge-web/components/repo/pulls-content.tsx
  • forge-web/components/repo/repo-header.tsx
  • forge-web/components/repo/repo-home-content.tsx
  • forge-web/components/repo/repo-scaffold.tsx
  • forge-web/components/repo/settings-content.tsx
  • forge-web/contexts/auth-context.tsx
  • forge-web/e2e/v2-private-members.spec.ts
  • forge-web/hooks/use-private-home.ts
  • forge-web/hooks/use-private-write.ts
  • forge-web/hooks/use-query-param.ts
  • forge-web/hooks/use-repo.ts
  • forge-web/lib/auth/controller.ts
  • forge-web/lib/auth/encryption-key.test.ts
  • forge-web/lib/auth/encryption-key.ts
  • forge-web/lib/auth/hd.ts
  • forge-web/lib/auth/vault.ts
  • forge-web/lib/private/index.ts
  • forge-web/lib/private/wrap.ts
  • forge-web/lib/repo/config.ts
  • forge-web/lib/repo/contract.ts
  • forge-web/lib/repo/issues.ts
  • forge-web/lib/repo/new-release.ts
  • forge-web/lib/repo/packs.ts
  • forge-web/lib/repo/private-content.ts
  • forge-web/lib/repo/private-members.ts
  • forge-web/lib/repo/private-rotation.test.ts
  • forge-web/lib/repo/private-session.live.test.ts
  • forge-web/lib/repo/private-session.test.ts
  • forge-web/lib/repo/private-session.ts
  • forge-web/lib/repo/refs.ts
  • forge-web/lib/repo/source.ts
  • forge-web/lib/repo/writes.ts
  • forge-web/lib/view/browse-fallback.ts
  • forge-web/lib/view/browse-source.ts
  • forge-web/lib/view/content-checks.ts
  • forge-web/lib/view/index.ts
  • forge-web/lib/view/issues-view.ts
  • forge-web/lib/view/private-nav.test.ts
  • forge-web/lib/view/private-nav.ts
  • forge-web/lib/view/private-packs.ts
  • forge-web/lib/view/repo-view.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

PastaPastaPasta and others added 24 commits September 27, 2026 06:13
Members decrypt a private repo in the browser: the vault holds the identity's encryption key, a per-repo session unwraps the reader's repo keys, resolves epochs and opens config, refs, issues, PRs, comments, reviews and sealed packs. Owners add and remove members with the key rotation of private-repos.md 5.5, and maintainers run the repair check of 5.6.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…mes out of URLs

Shared helpers replace duplicated identity fetches, base58 and hex helpers, sleeps and admit loops; dead exports removed. A private repo's path, ref and oid route params become per-tab tokens so decrypted names never reach browser history.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A lock during a load no longer leaks a session or a decrypted home; the private home re-reads with the plain home and past the session TTL; only unreadable wraps are skipped; decrypted browse and fallback caches go with the session; a renewal reports a dropped encryption key; registering a key needs an unlocked vault; removing one of two roles does not rotate; rotations resume only to the held key; error codes match the CLI; the compose notes no longer point at dg.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Write flows use their own uncached sessions and never retire the page's; closed sessions are never served; each session's decrypted browse state goes with it. Removing a maintainer who stays a writer rotates without excluding them. URLs are sealed for any address form of a member's repo, tokens are opened only on sealed params and a stale one says so. Registering an encryption key refuses when the identity already has one the phrase does not derive and shows its cost. Import wipes the file's keys on every path; renewal notices are joined.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ty review

Every config of an epoch at or above 1 carries prevEpoch/prevEpochKey (tlv.ts and vectors from feat/private-repos). Removing a maintainer first re-anchors each epoch they anchored, and is refused when one cannot be read; new epochs go above every epoch number seen; a removal re-runs the repair check after its rotation.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…pped it

When the remover's only accepted wraps for the current epoch come from the maintainer being removed, it posts a self-wrap of that key first (parity with the CLI's reanchor_before_removal), and the removal cost counts it. A remover holding the epoch only through the key chain is refused.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A rotation's self-wrap that already stands wins: a retry reads it back and goes on with its key, every wrap and the anchor carry a tag of their key in the write intent, standing wraps are read back and verified instead of trusted, and the confirmation requires the anchor to commit to our key and be readable as the write epoch. Every read of a removal's rotation drops the deleted membership even when a lagging node still lists it, and a rotation never chains from an epoch the removed maintainer anchored. Raw keys in opened anchors and sealed configs are wiped; encryption ops are bound to their key id; only keys usable for forge-core are adopted; the release warning says attachments are unencrypted; the remove dialog warns when the new key goes to a key this browser lacks.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
E306 no encryption key, E307 no key for this repo, E310 rotation or repair pending.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A rotation that removes anyone never resumes an earlier run, and one whose own self-wrap stands unseen stops and re-reads; before its anchor, every wrap it posted at that epoch is read back and must stay within the remaining members. No key goes out while the member list still changes between reads. A lost rotation runs the repair check. A maintainer's removal is refused when an epoch they anchored would fall to another key, and the rotation after it never chains from below the epoch that was current before it. A later rotation does not unsettle step 4. Private issue lists are keyed by the reader's session and dropped with it; switching identity ends private sessions. Pack standing is judged over all copies and a copy with no block height never qualifies. Release assets are refused on private repos, as dg does. Sealed config and wrap writes assert no plaintext.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The leak check and the resume rule agree on every remaining member, key or not. A rotation that fails after a removal runs the repair check on its own, and a refusal after the revoke points at Repair. A lost rotation reports lost. A maintainer's removal re-checks that no epoch changes key a few times before refusing, and never pays for its own re-anchor twice. Pack standing counts every copy only for a whole artifact checked against packHash; a ranged read is judged by its own copy.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Epochs exist only as a contiguous run from 0: a candidate anchor above the first gap is ignored with an epochGap alert, an anchor chains to exactly e-1, and a new epoch is always the current one plus one, so no high epoch number can stall rotations. A pending next epoch whose key already reached someone being removed is anchored burned (config tag 11): chain-only, never a write epoch, its content late unless a current member wrote it, and the repair check rotates past it. Three existing conformance vectors assert the old non-contiguous rule and fail until the shared vectors are regenerated with the spec change.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Repair rotates a burned current epoch even when no non-member holds it. A burn confirms its epoch n+1 anchor before building n+2, and stops on a lost race. Re-anchors keep the burned flag, and a fallback anchor must match the key, flag and chain pair. Epochs above the remover's readable run that the leaving maintainer set vanish instead of blocking the removal. Re-granting a maintainer whose old configs would change an anchor is refused, and so is adding a member while the current epoch is burned. The banner names who closed the epoch.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…t read

Matches the CLI. The rotation after the delete chains from the epoch that stays current, so a remover who can't read it is refused before anything is deleted.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A leaving maintainer's top epochs vanish only when they anchored all of them and no maintainer who stays holds any. Each fresh read re-checks this, and the rotation never chains from below a kept epoch it saw. Re-granting a maintainer is refused when a config of theirs waits above the current epoch. Step 4 refuses when a later anchor that predates ours now follows it. Repair is offered only with the current key, and the banner names who set an unreadable current epoch.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
One short-id helper and a shared currentBurned and chainFrom. The preempted verdict carries its owner, so there is no extra read. The vanishingEpochs wrapper is gone and stale doc comments are fixed. Also fixes the 'holdss' typo in the refusal.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Under the spec's new anchor rule, a config posted before the epoch below it had its key is never a candidate, so the pre-empting config in this test is ignored instead of refused.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… does

The rotation is one loop, matching forge-core keyring::rotate. A removal burns any epoch it resumes or adopts. Any run burns an epoch whose standing wraps reached a non-member or hold a key a member no longer uses, instead of getting stuck. A burn resumes the next epoch from its pending self-wrap and re-checks the member list first.

A maintainer removal predicts the fallback anchors from its first read and refuses before writing anything. The removal reports lost, pre-empted and mismatched rotations instead of swallowing them, and never runs repair twice. Remove is disabled only when the epoch the rotation chains from is unreadable. The remover is no longer named as a holder, and the Repair wording is softer. Dead fields are gone.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…held here

An adopted self-wrap must be to the key this browser holds, or nothing else is paid. A lost rotation is reported even when the repair after it fails. The two refusals now say what happened: an epoch was already closed, or another maintainer's config always comes first.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…hile anchoring

Before its burned anchor, a burn wraps that epoch's key to every remaining member, so any maintainer can finish it with Repair. Removing your own maintainer role is refused while you anchor an epoch. A refused re-grant suggests the writer role or a new identity. A re-run removal rotating past a burned epoch is now pinned by a test.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…n private repos

Takes lib/private/epoch.ts and tlv.ts verbatim from feat/private-epochs-contiguous (b63ec2e): the stated-after anchor rule, burned anchors without a key below, skipEpochKey, and writeEpoch null while a non-member holds the current key. The rotation posts a burned anchor with prevEpoch only and the next anchor with prevEpochKey plus skipEpochKey. A re-anchor repeats the whole chain link, and a fallback anchor must match it.

The plain grantMember and revokeMember refuse a private repo, whatever calls them. Only the private add and removal flows write membership documents there, through grantMembershipDoc and revokeMembershipDoc.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…tings

The leaving maintainer's own wraps never keep an epoch from vanishing. Before the role goes, the remover self-wraps every epoch it holds only through the leaver's wraps. A refusal names the maintainer whose config would take over. The new Playwright spec checks that a private repo's settings never offer the plain Add or Remove.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…pre-burn wraps

The key a rotation chains from is wiped even when the skip lookup refuses. A burn's pre-anchor wraps skip every member this run already wrapped or found standing, and the cost preview counts them. Staying maintainers who lose a dropped epoch are named too.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
An opened config's skipEpochKey, a raw key of an older epoch, was copied into the plaintext document the pages read. It is now dropped like prevEpochKey, and both are wiped after the open.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@PastaPastaPasta
PastaPastaPasta force-pushed the feat/private-repos-web-read branch from 122a3e0 to 409ea9f Compare September 27, 2026 11:14
@PastaPastaPasta
PastaPastaPasta merged commit b3f4eea into master Sep 27, 2026
5 checks passed
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