Skip to content

feat(private): seal issues, pull requests, comments and reviews in the CLI - #68

Merged
PastaPastaPasta merged 8 commits into
masterfrom
feat/private-collab-sealing
Sep 27, 2026
Merged

PastaPastaPasta merged 8 commits into
masterfrom
feat/private-collab-sealing

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

What

The CLI now seals the free text of issues, pull requests, comments and reviews in private repositories (docs/security/private-repos.md §4, §8). This is PR 2 of the private-repos plan. The web writers (#67) seal the same documents byte for byte, and a new shared conformance case checks that.

Sealing (forge-core collab)

  • collab::private::seal_props moves every present sealed field out of plaintext and into the TLV:
    • issue: title, body
    • PR: title, body, baseRefName, sourceRefName
    • comment: body, path
    • review: body
    • on any of them, an importer's imported.author and imported.url (TLV tags 13, 14: they name the source org, repo and people). imported.createdAt stays plaintext.
  • A PR's baseRefNameHash / sourceRefNameHash become HMAC(K_ref,e, name) (§4.5).
  • It then adds epoch and enc. Everything else stays plaintext as designed (§7): numbers, targets, sourceRepoId, headOid, draft, replyTo, reviewId, commitOid, lines and side, verdict, commentCount.
  • Collab seals on write when the repo is private:
    • comment, review, the importer's numbered creates, and the journaled allocated creates;
    • a renumbered retry re-seals for its new number, because the AD binds it.
  • Collab opens on read: issue, patch, lists, comments_counted, reviews.
    • What doesn't open counts as hidden.
    • A review that doesn't open is never counted as an approval.
    • A reader who holds no key at all gets E306 (the key source has no encryption key) or E307 (not a member / not wrapped) with the fix, instead of an empty list. An issue or PR that exists but can't be opened says so, instead of E102 "not found".
  • Keys are resolved once per command for reads (M8). Every sealed write re-resolves them first (§5.3), so a prompt or a long import never seals under an epoch that a rotation superseded. RepoService and Collab share one cached_keyring helper. A PR list folds every row against one decrypted reflog, instead of re-reading it per PR.
  • Private PR bases follow D-501 (fix(rules,dg,web): ref forced back to an earlier tip, and PR bases that do not exist (D-600, D-501) #65): read_private_merge_base takes the PR's opened-at time.
  • Collab no longer refuses private repos. Releases still refuse them, because notes and assets are not encrypted in this release (§12.5). dg label warns that label names are plaintext.

Other changes

  • Edits are judged too (§8.2). A document created in time but edited late by a removed author is Unreadable(lateEdit), shown as "edited after its author was removed; the original text is gone". A replace keeps only the new text, so showing it "as created" is not possible. This matches feat(web): create private repos and write sealed content from the browser #67. FetchedDocument carries $updatedAtBlockHeight.
  • Importer:
    • reads its mirror index through Collab, so it can find sealed provenance;
    • reads a private destination with the signer's keys, dry runs included;
    • skips releases on a private destination, and warns what stays readable.
  • dg repo view on a private repo you can't read now explains E306 / E307 instead of showing an empty repo.
  • dg issue view and dg pr view report hiddenComments. pr view also reports hiddenReviews, and the list commands say why documents were hidden.
  • On a private repo, a pending create's local journal file name is keyed with a per-install secret, so a title can't be guessed from it.
  • patches_from_* are public-only.
  • dg issue label warns that label names are plaintext.
  • Spec §4.3 gives per-type text caps: issue 5085, PR 5079, comment 5085, review 5088 bytes. The error message names the cap.

Conformance vectors (205 private vectors, up from 181)

  • New case private_collab_seal (19 vectors, two of them with imported provenance):
    • input: the properties the public writer would produce, plus the key, owner and a fixed nonce;
    • output: the sealed properties, or tooLarge;
    • covers issues, renumbering, PRs with and without a source branch, inline replies, reviews with and without a body, and the at-cap / over-cap limit for every type.
  • Edit vectors: private_doc_open__issue_edited_* (the late one is lateEdit) and …__issue_created_late_and_edited_is_late; plus …__tlv_imported_in_issue.
  • Both harnesses run them:

Coordination

Tests

Reviews

  • The simplifier's findings are applied (the refactor(private) commit).
  • Independent security review: no criticals. Every medium and low is fixed: imported provenance sealed, fresh keys before writes, the web updated height (in feat(web): create private repos and write sealed content from the browser #67), journal naming, patches_from_*, dry-run keys, late edits, escaping, the label warning.
  • Correctness review: the high item (the importer into a private destination) and every medium and low are fixed, with tests: E306 / E301, exists-but-unreadable, reflog memoisation, hiddenReviews, the EarlierUse height, typed tooLarge, and the e2e mint lock and base-hash assertion.

🤖 Generated with Claude Code

PastaPastaPasta and others added 4 commits September 27, 2026 06:33
…e CLI

forge-core Collab seals the free text of issue/patch/comment/review into enc on a private repo (collab::private::seal_props: title, body, branch names, path; patch hashes become HMAC(K_ref,e, name)) and opens it on read, counting what does not open as hidden; unreadable reviews are never counted. Keys are resolved once per Collab (one command), and a renumbered create re-seals for its number. Releases stay refused on private repos; labels warn they are plaintext.

Edits are judged by the late-content rule ($updatedAtBlockHeight, max with the created height) in Rust and TS. dg repo view explains E306/E307 instead of showing an empty repo. Per-type text caps (issue 5085, PR 5079, comment 5085, review 5088) in the spec and the error.

New shared conformance case private_collab_seal (17 vectors) and three edit vectors (201 total), with runners in both harnesses; git-remote-dash --dump-collab; e2e scenario 17 on minted identities.

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

Private collab reads require a key once (E306/E307 with the fix) instead of listing nothing; --dump-collab reaches comments and reviews through their issue or patch (they are not indexed by repo); scenario 17 accepts dedicated identities when minting is down.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Private PR bases follow D-501 too (read_private_merge_base takes the PR's opened_at, via pr_base_tips). The sealed-collab scenario is renumbered to 19 (17 and 18 are taken), mints under the shared qa-mint lock, and has its e2e README rows.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
One cached_keyring helper for RepoService and Collab; seal_if_private takes the content kind (TargetKind::content_kind); readable_all resolves keys once through private_keys/open_with; seal_props_with_nonce for the vectors only; open_doc takes the document by value; readable_target for issue/patch; the vector runner parses DocKind; dump_collab's by_target is a function. dg pr view reports hiddenComments like dg issue view.

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

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 28 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: 1f058926-fe2c-4bfa-b943-08960c37e442

📥 Commits

Reviewing files that changed from the base of the PR and between b82be64 and 46c21c3.

📒 Files selected for processing (55)
  • crates/dg/src/fmt.rs
  • crates/dg/src/issue.rs
  • crates/dg/src/label.rs
  • crates/dg/src/pr.rs
  • crates/dg/src/repo.rs
  • crates/forge-core/src/collab/mod.rs
  • crates/forge-core/src/collab/private.rs
  • crates/forge-core/src/collab/v2.rs
  • crates/forge-core/src/keyring.rs
  • crates/forge-core/src/platform/mod.rs
  • crates/forge-core/src/private/conformance.rs
  • crates/forge-core/src/private/doc.rs
  • crates/forge-core/src/private/mod.rs
  • crates/forge-core/src/private/tlv.rs
  • crates/forge-core/src/refs.rs
  • crates/forge-core/src/repo.rs
  • crates/forge-core/src/webhooks.rs
  • crates/forge-import/src/dest.rs
  • crates/forge-import/src/importer.rs
  • crates/forge-import/src/sink.rs
  • crates/forge-relay/src/daemon.rs
  • crates/forge-relay/src/ingest.rs
  • crates/git-remote-dash/src/admin.rs
  • docs/security/private-repos.md
  • e2e/README.md
  • e2e/cli/run.sh
  • e2e/cli/scenarios/19-private-collab.sh
  • forge-contracts/vectors/private_collab_seal__comment_at_cap.json
  • forge-contracts/vectors/private_collab_seal__comment_imported_author_only.json
  • forge-contracts/vectors/private_collab_seal__comment_inline_reply.json
  • forge-contracts/vectors/private_collab_seal__comment_over_cap.json
  • forge-contracts/vectors/private_collab_seal__comment_plain.json
  • forge-contracts/vectors/private_collab_seal__issue_7.json
  • forge-contracts/vectors/private_collab_seal__issue_at_cap.json
  • forge-contracts/vectors/private_collab_seal__issue_empty_body.json
  • forge-contracts/vectors/private_collab_seal__issue_imported.json
  • forge-contracts/vectors/private_collab_seal__issue_over_cap.json
  • forge-contracts/vectors/private_collab_seal__issue_renumbered_8.json
  • forge-contracts/vectors/private_collab_seal__patch_at_cap.json
  • forge-contracts/vectors/private_collab_seal__patch_no_source.json
  • forge-contracts/vectors/private_collab_seal__patch_over_cap.json
  • forge-contracts/vectors/private_collab_seal__patch_with_source.json
  • forge-contracts/vectors/private_collab_seal__review_at_cap.json
  • forge-contracts/vectors/private_collab_seal__review_empty.json
  • forge-contracts/vectors/private_collab_seal__review_over_cap.json
  • forge-contracts/vectors/private_collab_seal__review_with_body.json
  • forge-contracts/vectors/private_doc_open__issue_created_late_and_edited_is_late.json
  • forge-contracts/vectors/private_doc_open__issue_edited_after_rotation_late.json
  • forge-contracts/vectors/private_doc_open__issue_edited_by_member_shown.json
  • forge-contracts/vectors/private_doc_open__issue_edited_within_grace_shown.json
  • forge-contracts/vectors/private_doc_open__tlv_imported_in_issue.json
  • forge-contracts/vectors/private_doc_open__tlv_reserved_tag.json
  • forge-web/lib/private/conformance.test.ts
  • forge-web/lib/private/tlv.ts
  • tools/private-repos-vectors/gen.py

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 2 commits September 27, 2026 10:07
Private::write_keys replaces an expect at the call site; visibility() inlined; Arc import; scope read once in base_ref_tips; the patch hash fields set in one loop; sealing_error takes the error by value; nonce12 and no key clones in the vector runner; imports tidied in dg and git-remote-dash; doc comments corrected.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
PastaPastaPasta added a commit that referenced this pull request Sep 27, 2026
The web reader passed only $createdAtBlockHeight to open_content, so a removed member's edit of their own old-epoch issue or comment long after a rotation was shown. It now reads $updatedAtBlockHeight. Content created late stays 'late'; an edit that is late by the same rule is 'lateEdit' (the original text is gone), which maintainers see as 'edited after its author was removed; the original text is gone'. This matches the rule #68 adopts for the CLI.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
PastaPastaPasta and others added 2 commits September 27, 2026 10:35
…ling

Seal imported provenance: imported.author and imported.url move into enc (TLV 13, 14; createdAt stays), and the importer reads its index through Collab, reads a private destination with the signer's keys (dry runs too), skips releases there and warns what stays readable. Sealed writes re-resolve the keys before each write (§5.3); reads keep one load per command.

A document created in time but edited late by a removed author is Unreadable(LateEdit), said as such (a replace keeps only the new text); EarlierUse is judged by the newest write. E306 for a key source without an encryption key, E301 without an identity, and an existing but unreadable issue/PR says so instead of E102. pr list folds every row against one decrypted reflog; pr view reports hiddenReviews; patches_from_* are public-only; the private journal name is keyed with a local secret; the base name and label warnings are escaped/added; typed tooLarge in the vector runner; e2e mint lock falls back to flock and asserts a keyed base hash.

Vectors: 205 (issue_imported, comment_imported_author_only, tlv_imported_in_issue, issue_created_late_and_edited_is_late; edited_after_rotation_late is now lateEdit).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Takes #67's openContent late-edit wording (same rule as the vectors) and keeps both e2e README rows.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@PastaPastaPasta
PastaPastaPasta merged commit 0ffdd74 into master Sep 27, 2026
22 checks passed
PastaPastaPasta added a commit that referenced this pull request Sep 27, 2026
…al private edits

Private-repo edits of issues and comments now re-seal through #67's sealEdit and replace only enc/epoch (no plaintext ever leaves); without a seal context a private edit is still refused. The issue page and list use #68's privateComposeBlock / composeCost / SealedLimit. dg issue list reads private issues through readable_all (decrypted for members); the CLI edit still refuses private repos (no sealed CLI edit yet).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
PastaPastaPasta added a commit that referenced this pull request Sep 27, 2026
…chedDocument, open_for_write)

Rebased onto master after #67, #68, #72, #73 and #74: the settings sections use the AA text shades the contrast test requires; the test fixture fills FetchedDocument.updated_at_block_height; the archive check opens through Session::open_for_write so dg pr create stays within the line limit.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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