Repository navigation
feat: FORGE_RULES_V2 client rules and the event/authorEvent contract split - #9
Conversation
…rEvent event is now gated by maintainer or writer only; the issue/patch author path moves to a new authorEvent type whose kind is limited to close (1) and reopen (2) by the schema. A reader can now tell which gate admitted each document, so a revoked maintainer who authored a PR no longer leaves ambiguous merges. contract-validate gains --previous, which runs rs-dpp validate_update against the registered schema: removing the ownerRefersTo operands is refused as an incompatible change, so the split ships as a new registration. negative.sh covers the authorEvent lookup. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…vent split deploy-v2.mjs gains --only collab (register forge-collab alone against the recorded forge-core and group) and --force-new (supersede the recorded forge-collab with a new id). The new forge-collab is 6tm5ehZGoNSwenkCZkXjUm97Vt2bdXfFFsfh9KZ5N43W (nonce 3, 0.545473 DASH); 9fCcSGF3UmajGCNHuuDGz2ou3Gm3EXhrwB3SRS9ocm4Y is recorded as superseded. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
--force-new now supersedes only a record whose status is registered. A broadcasting record is the new contract of an interrupted run, which registerContract completes or retries, so rerunning the same command after a crash cannot register a third copy. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ce vectors forge-core::rules::v2 and forge-web/lib/rules/v2.ts: RoleOracle over current membership documents; issue/PR fold over event + authorEvent (event existence is authorization, authorEvent is close/reopen by the author only, merge needs a reachable oid); allocate_number with the 2n+100 ceiling; pack copy ordering, selection and supersedes-aware read order; count_approvals; is_well_formed; repo name validation and normalization. v1 fold effects are factored into shared helpers that v2 reuses, with v1 behaviour unchanged. Vectors gain an optional rules field (absent means v1); both harnesses dispatch on it, refuse unknown input keys, and assert 74 v1 + 93 v2 vectors ran. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… and well-formedness rules Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…a hash Every deployment record now carries schemaHash, the sha256 of the substituted schema JSON. --force-new supersedes only a registered forge-collab whose hash differs from the current schema, so rerunning it after success or a crash registers nothing. A rerun warns when a recorded contract was registered from a different schema, and a dry-run forge-core step is no longer checked against a leftover record. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…forge-collab authorEvent gains (repoId, $createdAt) so the repo activity feed reads both event types. Adding an index is refused on update, so forge-collab was re-registered on devnet moutai as CbsaT6oxuoESYhWuoJuPW9QikvAP7RS2x8NGQAYiwsMq (nonce 4, 0.555523 DASH); 6tm5ehZGoNSwenkCZkXjUm97Vt2bdXfFFsfh9KZ5N43W joins the superseded records. schemaHash is backfilled on every record from the schema it was registered from. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
TypeScript now orders every string by code point (compareStrings, UTF-8 byte order, as Rust does) instead of UTF-16 code units, in the event order, sorted sets and overlay paths. is_well_formed treats a review's body as optional (its content is the verdict and commitOid) and adds config; count_approvals documents that its input is filtered by is_well_formed first. TS allocateNumber rejects a count that is not a non-negative integer, and both ports state that the ascending query must be paged to the end of the contiguous run. Both harnesses now refuse unknown keys at every depth and gain a role_oracle case. 25 vectors added (118 v2 total): code-point ordering, role oracle, same-key stability, non-author reopen, base-at-ceiling gap, supersedes chain and cycle, review and config well-formedness, and the kept design choices (author reopen after member close, self-approval). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…forge-collab id Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Important Review skippedToo many files! This PR contains 132 files, which is 32 over the limit of 100. To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch. Upgrade to a paid plan to raise the limit. This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (132)
You can disable this status message by setting the 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. Comment |
…mirror lies Review #2/#4/#9: requests are limited to 4 per origin and a pack's URLs are raced 3 at a time; the 15 s deadline covers the response starting and then each gap between chunks, not the time spent queued; a URL that timed out gets one sequential retry before the pack is declared unavailable; URLs that failed outright are remembered for the session; range reads use the same list; a Platform pack failing cancels the external downloads; a partial clone is reused for 60 s, not the session, so a later view retries the mirrors. Review #8: a mirror serving bytes that fail the sha256 is shown as 'served bad data' and recorded separately in the ledger and trust detail. Review #5: a REF_DELTA whose base is in a skipped pack names that pack instead of failing with a bare indexer error. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
PR "B" of the forge-v2 client migration: the pure
FORGE_RULES_V2client rules in Rust and TypeScript, their conformance vectors, and one contract change. The rules contain no SDK or network code.Contract change:
eventsplit intoevent+authorEventeventin forge-collab used to be gated byownerRefersTo anyOf[maintainer, writer, issue-author, patch-author]. A reader could not tell which operand admitted an event: a maintainer who authored a PR and was later revoked left merges that the author path might have admitted, and the author path does not allow merges.event:ownerRefersTo anyOf[maintainer lookup, writer lookup]only. It still carries every kind.authorEvent:ownerRefersTo anyOf[issue author lookup + propertyAgreement, patch author lookup + propertyAgreement](the author operandseventhad before).kindis an integer1..2(close, reopen), so consensus refuses any other kind. The type is immutable and non-deletable, with indexestarget (targetId, $createdAt)andfeed (repoId, $createdAt).Why a new registration, not an update.
tools/contract-validategains--previous <registered schema>, which runs rs-dpp'svalidate_updateunder protocol 14. It refuses the split, because removingownerRefersTooperands is an incompatible change. It also refuses adding an index to an existing type. So forge-collab was re-registered on devnet moutai:CbsaT6oxuoESYhWuoJuPW9QikvAP7RS2x8NGQAYiwsMq(nonce 4), enrolled in group23iVLZABbVQ5a4heSa6GLVbVqSWr74JTSESSMTEYNd6o9fCcSGF3UmajGCNHuuDGz2ou3Gm3EXhrwB3SRS9ocm4Y(the four-operandevent) and6tm5ehZGoNSwenkCZkXjUm97Vt2bdXfFFsfh9KZ5N43W(the split, before review added theauthorEventfeed index; 0.545473 DASH)GdZYaEntYPiW9dvUGCHyeqN7H7qEocbSkuj81n341i3Ldeploy-v2.mjsgains three things:--only collab: register forge-collab alone, against the recorded forge-core and group.--force-new: supersede the recorded forge-collab with a new id.schemaHashon every record: sha256 of the substituted schema, backfilled on the existing records.--force-newsupersedes only a registered contract whose hash differs from the current schema. Rerunning the command after success or after a crash therefore registers nothing, and I checked this on moutai. A rerun warns when a recorded contract was registered from a different schema.negative.shadds fourauthorEventmutations, and all 21 are refused.docs/contracts/forge-v2.md§2, §3, §7 and §8 are updated.FORGE_RULES_V2 (
crates/forge-core/src/rules/v2.rs,forge-web/lib/rules/v2.ts)The TypeScript names are the same in camelCase.
eventapplies, because its existence proves a member wrote it and a later revocation does not undo that. AnauthorEventapplies only if it is a close or reopen by the target's author. Both types fold as one log in v1's($createdAt, $id)order with v1's per-kind effects. A merge applies only if itsoidis reachable from the base tip, and a merged PR cannot be reopened.ceiling = min(2n + 100, 2³² − 1);base= the largest taken number ≤ceiling(or 0); claim the first free number abovebase. The caller's ascending query must be paged to the end of the contiguous run. The exact semantics are in forge-v2.md §6.createdAtthenid; the first verified copy is read. Asupersedeslist is honoured only from the selected, verified copy. Superseded packs are read after the rest as a fallback, not dropped.is_well_formedfirst. Only reviews on the current head count, and only from a reviewer with a current membership document created at or before the review. The newest approve or request-changes review per reviewer stands; comment and unknown verdicts are ignored.encand has its kind's required plaintext field; a review has none, since its content is the verdict andcommitOid. In a private repo it has a non-emptyenc, anepoch, and no plaintext fields. This covers issue, patch, comment, review, ref update and config.^[a-z0-9][a-z0-9._-]{0,62}$. Normalization lowercases ASCII A–Z only.compareStringsinstead of<, which compares UTF-16 code units and disagrees with Rust on astral characters. The v1 TypeScript orderings now use it too.Two v1 behaviours are kept and documented: an author may reopen what a member closed, and a member's approval counts on their own PR. v1 rules are otherwise unchanged; the v1 per-kind effects, merge reachability and event order became shared helpers that v2 reuses.
Conformance vectors
Vectors take an optional
"rules": "v1" | "v2"field; absent means v1. All 74 existing vectors are unchanged, and 118 v2 vectors are added:fold_issue_v2__*fold_pr_v2__*allocate_number__*pack_copies__*approvals__*role_oracle__*well_formed__*repo_name__*Both harnesses (the Rust test at the bottom of
rules.rs, andforge-web/lib/rules/conformance.test.ts) dispatch onrules, refuse unknown input keys at every depth, and assert that at least 70 v1 and 110 v2 vectors ran. To confirm the new vectors actually run, I made one temporary change at a time; each was reverted:allocate_number__far_squatter_ignoredauthorEventlabels allowed to applycopies[1].supersede)<Gates
cargo fmt --all -- --check,cargo clippy --locked --workspace --all-targets -- -D warnings,cargo test --locked --workspace: pass (conformance_vectors: 74 v1 + 118 v2 vectors green)forge-web:pnpm install --frozen-lockfile,pnpm typecheck,pnpm lint,pnpm test: pass (325 passed, 3 skipped)tools/contract-validate(cargo +1.98.1): both contracts valid under protocol 14;negative.sh: all mutations refused🤖 Generated with Claude Code