Skip to content

feat: forge-v2 shared contracts for protocol 14 (core + collab, consensus writer gates) - #7

Merged
PastaPastaPasta merged 11 commits into
masterfrom
feat/forge-v2-contracts
Sep 25, 2026
Merged

PastaPastaPasta merged 11 commits into
masterfrom
feat/forge-v2-contracts

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds the protocol-14 forge-v2 data contracts (roadmap decision D-A): two shared contracts, forge-core and forge-collab, joined in one PV14 contract group. They replace the per-repo contract template and the registry. Also adds an offline validator that checks both against rs-dpp v4.2.0-beta.4 under PlatformVersion 14, a deploy script, and the spec. Both contracts are registered on devnet moutai.

  • forge-contracts/contracts/forge-core.json: repo, maintainer, writer, refUpdate, protectedRefUpdate, config, packManifest, manifestPart, chunk, release, label, repoKey
  • forge-contracts/contracts/forge-collab.json: issue, patch, comment, review, event, checkRun, webhook, profile, star, follow (star/follow are indexOnly)
  • tools/contract-validate: a standalone Rust crate with its own workspace, plus negative.sh
  • forge-contracts/scripts/deploy-v2.mjs: evo-sdk 4.2.0-beta.4, pinned in forge-contracts/sdk-v2
  • docs/contracts/forge-v2.md: the model, enforcement, client rules, private-repo key envelope, and measured cost

Access control, enforced at consensus

  • Grants are owner-only. maintainer/writer repoId refers to a permanent repo with propertyAgreement {"$ownerId":"$ownerId"}. Deleting the membership document revokes it.
  • Write-path types use a doctype-level ownerRefersTo of deletable lookups on (repoId, memberId):
    • maintainer or writer: refUpdate, packManifest, manifestPart, chunk, label, checkRun
    • maintainer only: protectedRefUpdate, config, release, repoKey, webhook
  • event is gated by maintainer OR writer OR the author of the target issue/PR. The author path is a permanent lookup on a unique author($ownerId, repoId, number) index, tied to targetId with {"targetId":"$id"}.
  • Non-deletable, because PV14 does not reference-check deletes: repo, refUpdate, protectedRefUpdate, config, packManifest, manifestPart, chunk, repoKey, issue, patch, event.
    • Platform-tier storage is therefore permanent, and Platform repack only consolidates.
    • dg repack/GC must stop deleting chunks and manifests (follow-up).
  • Pack-write unique indexes include $ownerId, so no writer can front-run another's slot. Readers pick the hash-verified copy, maintainers' copies first.

The rules left to clients are named in forge-v2.md §6:

  • event kinds by role;
  • gap-tolerant issue/PR numbering that ignores far-ahead squatters;
  • approvals counted only from members;
  • the pack and repoKey reader rules;
  • plaintext-or-enc.

Validation (offline, protocol 14)

The validator:

  1. parses each contract with full validation;
  2. re-parses its serialization format with full validation;
  3. applies the create transition's basic-structure rules, including the contract group fields;
  4. runs a port of drive-abci's registration-time reference validation (document leaves, identityPublicKey leaves, key-id references), resolving forge-collab's 9 cross-contract leaves against the in-memory forge-core;
  5. checks sample documents, well-formed and malformed;
  6. sizes a signed-shape DataContractCreate v1 and round-trips it through the node's untrusted decoder.

negative.sh (cargo +1.98.1) applies 17 single-rule mutations; each is refused with the expected error.

forge-core forge-collab
types / indexes 12 / 26 10 / 21
signed create transition 11,924 B (58.2% of 20,480) 11,314 B (55.2%)
registration fee 0.60 DASH 0.51 DASH
measured on moutai 0.605711 DASH 0.515157 DASH

Deployed on devnet moutai

Deployer 8HGxMu4atPn4jThH5h9X1MajzhoD3PRnzCRGrAsFcLcV; the ids are recorded in forge-contracts/deployments/devnet-moutai.json.

  • forge-core GdZYaEntYPiW9dvUGCHyeqN7H7qEocbSkuj81n341i3L
  • forge-collab 9fCcSGF3UmajGCNHuuDGz2ou3Gm3EXhrwB3SRS9ocm4Y
  • contract group 23iVLZABbVQ5a4heSa6GLVbVqSWr74JTSESSMTEYNd6o: owner and both enrolments verified on chain

A second run found both contracts on chain and broadcast nothing.

Test plan

  • cargo +1.98.1 run --manifest-path tools/contract-validate/Cargo.toml -- forge-contracts/contracts/forge-core.json forge-contracts/contracts/forge-collab.json
  • tools/contract-validate/negative.sh
  • cargo clippy --locked -- -D warnings and cargo fmt --check on the validator
  • node forge-contracts/scripts/deploy-v2.mjs --self-test (JS id derivation matches the rs-dpp vector)
  • Registered on moutai; a rerun is idempotent

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 36 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: e30b7605-179a-4909-b3ea-a4cd7b833f34

📥 Commits

Reviewing files that changed from the base of the PR and between 08271fa and 9b8996c.

⛔ Files ignored due to path filters (2)
  • forge-contracts/sdk-v2/package-lock.json is excluded by !**/package-lock.json
  • tools/contract-validate/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (12)
  • crates/forge-core/src/rules.rs
  • docs/architecture.md
  • docs/contracts/data-contracts.md
  • docs/contracts/forge-v2.md
  • forge-contracts/contracts/forge-collab.json
  • forge-contracts/contracts/forge-core.json
  • forge-contracts/deployments/devnet-moutai.json
  • forge-contracts/scripts/deploy-v2.mjs
  • forge-contracts/sdk-v2/package.json
  • tools/contract-validate/Cargo.toml
  • 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 and others added 11 commits September 25, 2026 01:32
…col 14

forge-core (repos, maintainer/writer membership, refs, packs, config, releases, labels, wrapped repo keys) and forge-collab (issues, PRs, comments, reviews, events, check runs, webhooks, profile, stars, follows) replace the per-repo contract template and the registry.

Write-path types are gated at consensus with ownerRefersTo lookups on the membership documents; grants are owner-only through a $ownerId propertyAgreement against the repo. Audit-critical types are non-deletable because PV14 does not reference-check deletes. forge-collab names forge-core through FORGE_CORE_CONTRACT_ID, substituted at deploy.

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

tools/contract-validate is a standalone crate (its own workspace, so the main workspace's pinned SDK is untouched). Under PlatformVersion 14 it parses each contract with full validation, applies the create transition's basic-structure rules, ports drive-abci's registration-time reference validation so forge-collab's references into forge-core are checked against the in-memory core contract, checks well-formed and malformed sample documents, and reports the signed-shape create transition size and registration fee.

negative.sh applies 14 single-rule mutations and requires the validator to refuse each one.

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

Registers forge-core with a DataContractCreate v1 that creates the contract group and enrols the contract, then substitutes forge-core's id into forge-collab and registers it enrolled in the same group. Supports devnet (devnetName, explicit DAPI addresses; moutai's are built in), testnet and mainnet through evo-sdk 4.2.0-beta.4, pinned in forge-contracts/sdk-v2 apart from the v1 script's SDK.

It checks the network runs protocol 14, rebuilds each contract with full validation before signing, records each step in deployments/<network>.json before and after broadcasting so a rerun resumes, verifies the group and both enrolments on chain, and has --dry-run and --self-test (the id derivation checked against the Rust validator's vector).

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

docs/contracts/forge-v2.md covers who can write each type and where that is enforced, why audit types are non-deletable under protocol 14, the private-repo key envelope, which v1 client rules consensus now replaces and which remain, and the measured sizes and fees. data-contracts.md points to it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
chunk is now non-deletable: Platform-tier storage is permanent and repack on that tier only consolidates. release is maintainer-gated. The unique indexes of packManifest, manifestPart and chunk include $ownerId, so no writer can claim another's slot, and repoKey is unique on (repoId, memberId, epoch, $ownerId). repo gains an editable displayName beside the immutable name slug. webhook is mutable with repoId and hookId immutable, so disabling a hook is an in-place replace re-checked against the maintainer gate.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The contract group id is derived from forge-core's broadcast nonce and recorded with it, so a resumed deploy never reuses a stale group id. Nonces are masked to their low 40 bits as rs-dpp does. A step found on chain has its record completed (status, cost from the pre-broadcast balance, owner) instead of being skipped. A disabled CRITICAL key is refused.

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

Ports drive-abci's identityPublicKey leaf and key-id reference checks (40125), and re-parses each contract's serialization format with full validation as a node does. negative.sh pins cargo +1.98.1 and adds three mutations for the new checks.

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

Names the client rules consensus leaves in place: event kinds by role, gap-tolerant issue/PR numbering that ignores far-ahead squatters, approvals only from members, the pack reader rule (hash-verified, maintainer copies first), the repoKey reader rule (maintainer writer, verified key-check value) and plaintext-or-enc. Records that Platform chunks are permanent and that dg repack/GC must stop deleting them, and updates the measured sizes and fees.

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

On moutai the balance read right after broadcastAndWait returned the pre-transition value, so forge-collab was recorded at 0 DASH. The script now polls until the balance changes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
forge-core GdZYaEntYPiW9dvUGCHyeqN7H7qEocbSkuj81n341i3L and forge-collab 9fCcSGF3UmajGCNHuuDGz2ou3Gm3EXhrwB3SRS9ocm4Y, enrolled in contract group 23iVLZABbVQ5a4heSa6GLVbVqSWr74JTSESSMTEYNd6o, registered by the moutai DEPLOYER for 1.120868 DASH in total. forge-collab's cost comes from a balance re-read, because the script's own read was stale.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@PastaPastaPasta
PastaPastaPasta merged commit 406c984 into master Sep 25, 2026
3 checks passed
PastaPastaPasta added a commit that referenced this pull request Sep 25, 2026
Review #1: a page out of refNameHash order, holding a row at or below its '> last' bound, or a round that would not advance 'last' now stops the scan at once, and the answer comes from the reflog read of both types alone, deduplicated by $id (it used to keep paging and union). Both clients; a mock node that ignores the bound is covered. Review #7: the module docs now say what the prevOid check cannot see (a missing newest update or a whole ref) and that a 100+ update ref's equality read still carries protocol 13's same-$createdAt boundary gap until forge-v2.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
PastaPastaPasta added a commit that referenced this pull request Sep 29, 2026
Issues and PRs share one dense sequence, so the demo's PRs are #5 (approved), #6 (merged) and #7 (the review-parity draft). e2e/seed-summary.ts reads pulls {approved, merged, reviewParity} from $FORGE_SEED_SUMMARY, else forge-contracts/deployments/fixtures/devnet-<devnet>.json, lazily, and fails loudly without them. The explore jump-box case for an issue and a PR sharing a number is gone (a number is one or the other); the draft is read from its kind-14 transition.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
PastaPastaPasta added a commit that referenced this pull request Oct 1, 2026
issues-paging (AXWiBed2j4e687ahukRWK81CwMExp4KLh6hJUqbnqmAx) is seeded on sakura by F1OWNER AQTWh1SA… with #7 assigned to F1COLLAB AJpWoHMx…, and explore-fill-01..25 by explore-filler EKL1ysqq…, so the r1-r4 and g2 specs have their data. e2e/README records the sakura ids.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
PastaPastaPasta added a commit that referenced this pull request Oct 28, 2026
- A board spanning repositories showed each card's whole owner/name
  label: a 44-character identity id that truncated the number away on
  cards and cut table titles to one letter. Cards, table rows, roadmap
  lines and the item panel now show `name #12` (ItemRef), the full
  label as the tooltip; repo: matches an owner's whole id or DPNS name
  for every repository, not a shortened id nobody can type.
- The table's Group picker had no None, and picking Status cleared the
  grouping: a table could not be grouped by Status at all.
- A roadmap could not be switched to plot two date fields when the board
  has an iteration field: a Dates picker sets view.date.
- The item panel sat 12px down the viewport (the page's space-y margin
  on a fixed layer); it stayed open on "Item not on this board" after
  Remove; its link read "Open issue" beside the state "Open issue".
- A keyboard move into another column lost the focus (the card's new
  element renders after the drop); it is now refocused there.
- A label defined from the item panel showed the fallback colour on the
  cards until a reload: the page reads the definitions again when an
  item carries a label they lack.
- Light-theme contrast: the drag ghost's dark-mode note and the card and
  settings grips (lib/design/contrast.test.ts).
- "Show archived" shows only archived items: renamed "Only archived".
  The filter box's example names this board's columns and fields; a
  single unresolved qualifier "names nothing"; settings no longer says
  closed items go to Done on a board without one; quick add says
  "Puts #7 in Done" (it moves an item already on the board).
- Settings' column and field rows line up whatever chips they carry; the
  new-board templates read from the top; the Boards list puts the most
  recently changed board first; the issue sidebar's controls share one
  height; the roadmap's today marker no longer crosses header labels.

Co-Authored-By: Claude Opus 5.5 <[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