Skip to content

feat(contracts): schema RC1 for the bonsia registration (PR-1) - #170

Merged
PastaPastaPasta merged 8 commits into
wipe/beta7from
feat/schema-rc1
Sep 29, 2026
Merged

PastaPastaPasta merged 8 commits into
wipe/beta7from
feat/schema-rc1

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Owner

PR-1 of the RC1 plan (design/SCOPE-DECISION.md, WIPE-DECISIONS D-10..D-12). It adds the schema RC1 for the fresh registration on bonsia: one combined build of forge-core, forge-collab and forge-community, the registration checks a contract parse cannot run, accept/refuse vectors for every rule, and the deploy and doc changes that go with them. PR-2 registers it on bonsia and runs the live suite.

The build: forge-contracts/schema/build.py

It applies every RC1 item behind a flag to schema/base/ (the #154 build) and writes forge-contracts/contracts/*.json plus registered/forge-core.v1.json. CI runs build.py --check, so a hand edit to a contract fails.

  • Layout (D-11).
    • O-01: event, authorEvent and milestone move to forge-community.
    • O-02: runner moves to forge-community.
    • O-03: repoKey moves to forge-collab.
    • forge-community refers to forge-collab through FORGE_COLLAB_CONTRACT_ID.
  • P0.
    • R-01 ref grammar, with @{ refused.
    • R-02 and R-03: a private repo's documents carry no plaintext, proved by a vis stamp.
    • R-04 import provenance (asMember).
    • R-06 member consent.
    • R-07 https URLs.
    • R-08 pinned check sources.
  • P1.
    • R-09 complete Platform packs (manifestPart and offsetIndexParts are removed).
    • R-10 oid width.
    • R-11: kind 3 is the history index and kind 4 is release assets.
    • R-12 repo shape.
    • R-13 wraps go to members only.
    • R-14 reply roots.
    • R-15 the lock bit: kinds 3/4/18/19 carry ±16, and state is the sum mod 16.
    • R-16 member verdicts, with 4/5 for non-members.
    • R-17 check-run times.
    • R-18 private CI.
    • R-19 public-only hooks.
    • R-20 topics, capped at 20.
    • O-04 the release ledger.
    • O-05 proved pack bytes.
    • O-06 the public Explore feed.
    • O-07 check outcome.
    • O-08 public-only Trending.
  • Zero-fee grammar. INV-11, CL-7, and CL-8 without a cap.
  • COMM-9. Provisional: the step-8 fee gate decides whether it stays.
  • Off. protected_ref (R-05), ref_ledger (O-09) and label_tags (O-10).
  • Stamp name. vis everywhere.
  • Flag dependencies. They are enforced, because a where naming a stamp that is off would fail registration with 40126.

Sizes (rs-dpp v4.2.0-beta.7, full parse). No D-12 cut was needed.

forge-core forge-collab forge-community
gate bytes (target 17,408, ceiling 17,832) 16,143 16,475 16,496
signed create transition (limit 20,480) 16,323 B 16,581 B 16,602 B
registration fee 0.64 DASH 0.43 DASH 0.60 DASH

The pinned wasm evo-sdk (beta.7) parses all three with full validation.

Registration-only checks: forge-contracts/schema/wherecheck.py

This mirrors drive-abci data_contract_reference_validation/v0: 40121, 40122, 40126, 40131 and 40137. The 40137 check includes the target index kind, indexOnly and moving key parts. A feature the mirror does not port makes it fail closed instead of passing. --self-test proves it sees each error through mutations. CI runs it next to tools/contract-validate, which carries the Rust port of the same checks.

Vectors: forge-contracts/vectors/rc1/ (389 cases)

schema/vectors.py generates them, and every rule has either a refusing case or a LIVE_ONLY entry: rules that read a total, a time or a height are judged in PR-2's live suite. Each refused case names its reason: a schema keyword, a rule name, maxBytes, or a consensus code. The format is in the README; a case may also name another signer (owner) and use {"$id": "<base58>"} and {"$hex": …}.

  • tools/contract-validate --vectors replaces the hand-written samples. It judges every case the way a node's create structure validation does: the document schema and rules, then distinctFrom (10419) and the encryptedFor shape (10420). A refusal must happen for the reason the case names. b7gate --cases in dash-forge-qa runs the same checks.
  • negative.sh generates one mutation per rule (each must fail for that rule) and adds the RC1 registration negatives: 133 mutations, all rejected.

Deploy and clients

  • deploy-v2. Registration goes core → collab → community. Each registered id is substituted into the later contracts, so forge-community gets forge-collab's id. --only community confirms the recorded forge-collab on chain before naming it.
  • Tests. The Rust and TypeScript private vectors parse repoKey from forge-collab; the vectors themselves and the wrap builders are unchanged. The event late-rule tests read forge-community.
  • Web. source.ts routes event, authorEvent, milestone and runner to forge-community, and repoKey to forge-collab.

Docs

  • docs/contracts/forge-v2.md is at RC1:

    • the layout;
    • the vis stamps and what each is proved against;
    • the lock bit;
    • release assets as kind 4;
    • a new Frozen at mainnet section;
    • sizes and fees;
    • deploy order.

    The trust set for upstreamNumber and imported provenance is now one rule: a writer proved to be a member on chain (R-04).

  • Also updated: release-asset-manifest.md (kind 4), economics.md, and the mainnet runbook, which covers readonly for all three contracts.

Checks

  • cargo fmt, cargo clippy -D warnings and cargo test --workspace all pass.
  • forge-web: tsc, vitest run (3,078) and lint all pass.
  • build.py --check, vectors.py --check, wherecheck.py and --self-test, contract-validate --vectors and negative.sh all pass locally.
  • playwright (read-only, devnet moutai) cannot pass anywhere right now.

Review

code-review-validator found nothing blocking. Its should-fix items are in af0b430. Among them:

  • a branch named @ is refused;
  • flag dependencies are enforced;
  • the 40137 port is extended;
  • a refused vector must name its why;
  • negative mutations must fail for their own rule;
  • --only community reconciles.

Two items were not taken:

  • a JSON-path suffix on schema-keyword reasons, which would change the vector format the client agents already use;
  • porting the 40125 key-id checks to Python (contract-validate's Rust port covers them).

The simplification pass's safe items are applied.

🤖 Generated with Claude Code

PastaPastaPasta and others added 8 commits September 29, 2026 16:16
…t/refuse vectors

forge-contracts/schema/build.py applies the RC1 items (WIPE-DECISIONS D-10..D-12) to the #154 base schemas behind flags: the O-01/O-02/O-03 layout, every P0/P1 rule except protected_ref, ref_ledger and label_tags, INV-11, CL-7, CL-8 (no cap), R-01 with @{ refused, COMM-9, topics capped at 20 and the vis stamp. Gate sizes (rs-dpp v4.2.0-beta.7): core 16,150 B, collab 16,475 B, community 16,496 B, all under the 17,408 B target.

wherecheck.py mirrors drive-abci's registration-only reference checks (40121/40122/40126/40131/40137) with a mutation self-test. vectors.py writes 353 accept/refuse cases to forge-contracts/vectors/rc1/, each refusal naming its schema keyword or rule.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…d literal ids and bytes

contract-validate --vectors <dir> replaces the hand-written sample documents: every accepted case must pass and every refused one must fail for the reason it names (schema keyword, rule, maxBytes or code). A case may name its signer ("owner": byte or base58), and a document may write {"$id": "<base58>"} and {"$hex": "..."}.

negative.sh follows the RC1 layout (repoKey in collab; event, authorEvent in community), generates one without-<type>-<rule> mutation per rule a vector refuses by, and adds the new registration checks (vis where-pairs, consent and asMember findBy, check sources, reply agreement, one $def per type): 133 mutations, all rejected.

contracts.yml checks that build.py and vectors.py reproduce the committed files, runs wherecheck.py and its self-test, and passes --vectors. vectors.py fails when a rule has neither a refusing vector nor a live-only entry.

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

forge-community's events refer to forge-collab's issues and PRs through FORGE_COLLAB_CONTRACT_ID. deploy-v2 now substitutes every registered contract's id into the ones after it (core -> collab -> community); --only community uses the recorded forge-collab id, and --only collab warns when forge-community still names another forge-collab. The self-test loads each schema with only the earlier contracts' ids.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
repoKey is a forge-collab type and event a forge-community type (O-03, O-01): the wrap tests and private conformance vectors (Rust and TS) parse forge-collab with forge-core's placeholder filled, and the event late-rule tests read forge-community. The deploy-v2 test follows the new type split and the FORGE_COLLAB_CONTRACT_ID substitution. No vector or wrap builder changes: callers pass the collab contract for repoKey.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
- build.py: a branch's first component is never `@` alone (git's HEAD); flag dependencies are enforced (a where on a stamp that is off would fail registration with 40126); --check refuses --off.
- wherecheck.py: the 40137 checks of reference_lookup.rs (indexOnly target, a key a replace can move, system-property kinds), a reference to a later or unknown contract is 40121, documentsCanBeDeletedContractDefault and moderator delete, unported features fail closed; more self-test mutations.
- vectors: byte caps (maxBytes, the 5120-byte field limit), enc without epoch, chunk part size and checkRun enums; '@' refused as a default branch.
- contract-validate: a refused case must name its reason and an accepted one none.
- negative.sh: generated rule mutations must fail for their rule, a type left with no rule drops the empty propertyConstraints, an empty rule list fails.
- deploy-v2: --only community confirms the recorded forge-collab on chain before naming it; the self-test checks forge-community names forge-collab.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
forge-v2.md follows the RC1 build: the three-contract layout, the vis stamps and what each is proved against, consent and asMember, the lock bit (sum mod 16), packs, releases, topics, CI and hooks, a Frozen at mainnet section, measured sizes and fees, and the deploy order with the collab id substituted. Release assets are packManifest kind 4. economics.md and the mainnet runbook drop manifestPart, the deletable release and the two-contract readonly note.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…munity, repoKey to forge-collab

The RC1 layout (O-01, O-02, O-03): the type-to-contract map matches the three schemas again, which source.test.ts checks against forge-community.json.

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

After the document schema a node's create runs validate_distinct_from_properties (10419) and validate_encrypted_property_shapes (10420) (drive-abci document create advanced structure v1). contract-validate --vectors now runs both, and the vectors refuse a starBeat on the signer's own repo, following yourself, a 40-byte wrap and a 33-byte webhook secret. The README no longer calls distinctFrom chain-only.

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

coderabbitai Bot commented Sep 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 62b32c79-f027-4755-a55a-45f2600c0f3f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

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