Skip to content

feat(contracts): forge-collab revision for GitHub-parity PR review - #48

Merged
PastaPastaPasta merged 1 commit into
masterfrom
feat/review-parity-contract
Sep 27, 2026
Merged

PastaPastaPasta merged 1 commit into
masterfrom
feat/review-parity-contract

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Owner

PR 1 of the GitHub-parity review plan (docs/design/review-parity-spec.md §7, committed here). This PR changes the forge-collab contract, registers the new one on moutai, re-seeds the fixture, and adds live proofs that each new gate is enforced at consensus. The rule functions, vectors and writers come in PR 2.

Registered

forge-collab BMfPmaEiMqDp64NDa4Am79VoRpZ9MPVNnCUy6i3UiyWi on devnet moutai:

  • nonce 10, in the same contract group; forge-core is unchanged.
  • signed size 14,287 B of the 20,480 B limit; 12 types, 27 indexes.
  • cost 0.616306 DASH.

The committed forge-collab.json hashes to the schemaHash recorded in deployments/devnet-moutai.json. The recorded id feeds forge-core's network.rs, forge-web's deployments.ts, the e2e helpers and the seeder. One hard-coded copy, in wallet-protocol.test.ts, is updated here.

Schema changes (spec §3, as registered in §3.9)

comment

  • New startLine.
  • New reviewId: a deletableDocument reference to a review, with propertyAgreement {repoId: repoId, targetId: patchId, $ownerId: $ownerId}. Only the reviewer can attach comments to their review, and only on that review's PR. Consensus enforces this; another reviewer gets 40127, shown live.
  • The anchor fields are now immutable.
  • New reply (replyTo) index, marked nullSearchable: false, so comments without replyTo get no index entry.

review

  • New commentCount.
  • The patch (patchId, $createdAt) index is now rangeCountable, which gives a provable review count per PR.

patch

  • New draft.
  • headOid, draft and the four ref-name fields are now immutable. A replace that moves headOid gets 40128.
  • The source index becomes sourceRef (sourceRepoId, sourceRefNameHash). Queries on sourceRepoId alone still use it.

issue, patch, comment

  • $updatedAt and $updatedAtBlockHeight are now required. Readers get "edited" markers, and the private late-content rule can judge edits.

event

  • New refId, with a sparse addressee (refId) index.
  • Optional enc/epoch with dependentRequired (private-repos §13 item 6). Nothing writes these yet.

authorEvent

  • kind is now enum [1, 2, 9, 10, 11, 12, 13, 14, 16]. The author may resolve threads, request reviewers, mark draft/ready and move the head. The schema refuses author merge, label, assign, retarget and dismiss.
  • New refId and oid, plus a sparse addressee (refId) index.

policy (new type)

  • Maintainer-gated, immutable and non-deletable.
  • Fields: requiredApprovals 0–10, approverRole, requireChecks, and a mergeMethods bitmask.

Where protocol reality changed the spec

Details are in spec §3.9–3.11 and forge-v2.md §6.1.

  • propertyAgreement keys are the referring properties. The spec wrote patchId → targetId; the schema has targetId: patchId.
  • The spec's (refId|replyTo, $createdAt) indexes would add an entry for every event and comment. The registered indexes are single-property with nullSearchable: false, so only documents that set the field pay.
  • Open/closed counts cannot be count trees. Open is a fold over event + authorEvent, and merge validity depends on the base branch history. A stored state field could only live on the author-owned document, and members close and merge. So those counts stay client-side, as fix(web): count only open issues and pull requests in the repo tabs #44 already does.
  • Comment and review counts are provable, through the rangeCountable (target, $createdAt) indexes read prefix-to-last. rs-drive has this form; the book doesn't document it yet. A composite counts sub-query uses the same index picker.
  • A patch replace keeps its epoch, because its ref-name hashes are frozen HMACs under that epoch. Also, the late-content rule now covers edits through $updatedAtBlockHeight. Both are in private-repos §4.5 and §8.2.
  • Costs: steady-state issue and comment costs are unchanged (within 2%). The first write to a new target also creates its index subtree, which adds roughly 10–25M credits. The measured costs are in the spec §3.11 table.

Earlier on the same day, nonces 8 and 9 registered two iterations of this schema: one with non-sparse indexes, one without $updatedAtBlockHeight. Both are recorded as superseded.

Tests

  • tools/contract-validate passes: full PV14 parse, registration reference checks, 25 sample documents accepted and 18 malformed ones refused.
  • negative.sh passes, including 5 new mutations.
  • The deploy dry run matched the validator's size.
  • Live on moutai (FORGE_LIVE=1 … vitest run lib/repo/v2.live.test.ts lib/private/private.live.test.ts): every changed type is read back from the re-seeded fixture (PR feat: make the pull-request workflow observable and honest #3, the policy) through the new indexes and counts. In a scratch repo, the refusals and an author replace are checked. The existing fixture test and the private-repo test still pass.
  • pnpm test passes: 940 tests. cargo test -p forge-core network passes.

The fixture now also has issue #4. PR #3 took #3 as a PR number, and the jump-box spec needs a number that is only an issue.

🤖 Generated with Claude Code

Registers forge-collab BMfPmaEiMqDp64NDa4Am79VoRpZ9MPVNnCUy6i3UiyWi on devnet moutai (nonce 10, same group, forge-core unchanged) from the review-parity schema of docs/design/review-parity-spec.md section 3: comment.startLine and comment.reviewId (a deletableDocument reference to the review with a repoId, targetId=patchId and $ownerId agreement, so only the reviewer attaches comments, on its PR), review.commentCount, patch.draft, patch headOid/draft/ref names immutable, event and authorEvent refId, authorEvent oid and kind enum [1,2,9,10,11,12,13,14,16], optional event enc/epoch, a maintainer-gated non-deletable policy type, $updatedAt and $updatedAtBlockHeight on issue/patch/comment, sparse reply/addressee indexes, sourceRef (sourceRepoId, sourceRefNameHash) and rangeCountable review counts per PR.

The read fixture's collab documents are re-seeded under the new id (the seeder now archives collab steps when forge-collab changes) with a review-parity PR #3, issue #4 and a policy; the live test reads every changed type back, proves the refusals at consensus in a scratch repo (40127 reviewId agreement, 40120 writer policy and non-author authorEvent, 40128 headOid replace, schema refusal of author merge/label/dismiss) and an author replace. Spec section 3.9-3.11 records what protocol 14 changed and measured costs; forge-v2.md and private-repos.md follow (edits keep a patch's epoch; the late-content rule reads $updatedAtBlockHeight).

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 11 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: 2fe4c55b-52c4-487f-a194-0a0ed7e17d12

📥 Commits

Reviewing files that changed from the base of the PR and between 9453646 and a4bd084.

📒 Files selected for processing (14)
  • docs/contracts/forge-v2.md
  • docs/design/review-parity-spec.md
  • docs/security/private-repos.md
  • forge-contracts/contracts/forge-collab.json
  • forge-contracts/deployments/devnet-moutai.json
  • forge-contracts/scripts/seed-v2-fixture.mjs
  • forge-web/e2e/helpers.ts
  • forge-web/e2e/v2-reads.spec.ts
  • forge-web/lib/auth/wallet-protocol.test.ts
  • forge-web/lib/repo/contract.ts
  • forge-web/lib/repo/v2.live.test.ts
  • forge-web/lib/sdk/cost.ts
  • tools/contract-validate/negative.sh
  • tools/contract-validate/src/main.rs

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

Copy link
Copy Markdown
Owner Author

@coderabbitai review


🤖 Posted autonomously by Claude on behalf of pasta.

@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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