Repository navigation
feat: compare two contract versions, judged by the update rules (and ?url= links) - #2
Merged
Merged
Conversation
?url=<link>, or a link typed into the contract id box, fetches a contract JSON file and diagrams it like pasted JSON, without the SDK: a contract in a pull request that is not registered yet opens from one shareable link. - GitHub page links (github.com/<owner>/<repo>/blob|raw/<ref>/<path>) are fetched from raw.githubusercontent.com, since github.com pages are HTML and refuse cross-origin reads. Only http(s); files over 5 MB are refused; HTTP, CORS and non-JSON failures get their own message. - The link lands in the input box and the page URL, and names PNG / SVG exports. - The Vite dev server reads `?url` as its asset-import query and answered such page requests with 403; a dev-only plugin serves the app for them. Static hosting is unaffected. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A Compare mode diagrams two versions of a contract as one: the union of both, with added parts green, removed parts struck out in red and changed parts amber, for document types, properties, indexes, property constraints and reference edges; unchanged types are dimmed or hidden. - Base and head are each a registered contract id, a link to a contract JSON file, an example, or none. A GitHub pull request link lists the PR's changed JSON files and compares one at the merge base against the head, as GitHub's Files changed tab does (public REST API, no sign-in). - Deep links: ?pr=<PR link>&file=<path>, ?base=<source>&head=<source>. - The Changes panel lists every change as before -> after, grouped by document type; clicking one centers its type and opens it in the inspector, which shows the change on top. - Each change is judged by its keyword's "On update" rule in the Dash Platform Book: refused with the consensus error the book names (10246, 40212, 10217, 10276, 40002, 10212, ...) and a link to the rule, or flagged to check where the schema text alone does not settle it (integer storage width, schemaDefs compatibility). The version and readonly rules apply only when something changed. Config defaults are filled in on both sides so a fetched contract and a file compare equal. - The model keeps each property, index and type schema as written, which the comparison reads. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 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 |
This was referenced Sep 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Basic explanation
What this does: Two additions to the visualizer.
?url=: it opens any contract JSON file from a link. This was pushed to feat: read Platform 4.2 contracts (declared references and protocol 14 keywords) #1 after feat: read Platform 4.2 contracts (declared references and protocol 14 keywords) #1 had merged, so it never reachedmain; it is included here.Value:
Risks: Low. The site stays read-only.
What changed
Compare mode
example:<key>, or empty for no contract.src/github.ts).?pr=<PR link>&file=<path>and?base=<source>&head=<source>(plusnetwork/devnetwhen a source is a contract id).+), removed parts struck out in red (−) and changed parts amber (~), for document types, properties, indexes, property constraints, reference edges and external nodes. Unchanged types are dimmed, or hidden with hide unchanged types. A red✕marks every part a platform update would refuse.Verdicts (
src/model/updateRules.ts)Each change is judged by its keyword's On update rule in the book's Contract Keywords part:
IncompatibleDocumentTypeSchemaError(10246),DocumentTypeUpdateError(40212),DataContractInvalidIndexDefinitionUpdateError(10217),DataContractInvalidRequiredFieldsUpdateError(10276),DataContractConfigUpdateError(40002),InvalidDataContractVersionError(10212),DataContractUpdateActionNotAllowedError(40004),IncompatibleDataContractSchemaError(10213),DataContractUpdatePermissionError(40003),DataContractIsReadonlyError(40001).enumvalue that may change how the integer is stored, and a changedschemaDefsentry that must stay compatible.maxLength,maxItems,maximumandmaxBytesmay be raised or removed;minLength,minItemsandminimummay be lowered or removed;enummay gain values;immutablemay gain entries;requiredmay gain only a property the same update adds withrequiredSinceequal to the new version. A typed array keeps itsmaxItems, and a byte array keeps its fixed length.Load a contract from a link (
?url=)?url=<link>, or a link typed into the contract id box, fetches a contract JSON file and diagrams it like pasted JSON, without the SDK.github.com/<owner>/<repo>/blob|raw/<ref>/<path>) are fetched fromraw.githubusercontent.com; other hosts must allow cross-origin reads. Only http(s) links are accepted, files over 5 MB are refused, and HTTP errors, CORS failures and non-JSON bodies each get a clear message.?urlas its own asset-import query and answered such page requests with 403. A dev-only plugin invite.config.tsserves the app for them; static hosting (Pages) needs nothing.Other
written/schema), which the comparison reads.loadContractJson(insrc/sdk/contract.ts) loads any source as JSON for both sides.Before and after
Reviewing PastaPastaPasta/yappr#577 (
contracts/pollr-contract.json):?pr=https://github.com/PastaPastaPasta/yappr/pull/577&file=contracts/pollr-contract.json. Thepollcard is outlined amber and shows a green+ optionsContiguousrow in its property constraints, with the rule written as a formula. The Changes panel says "As an update of the base, the platform would refuse one change". Under the change, it shows✕ 10246 IncompatibleDocumentTypeSchemaError: A propertyConstraints rule may not be added, removed or changed on an existing type, with a link to the rule.A registered contract against a proposed file,
?base=EG7RGfV8fDTayC2FyVr8HwdpJh3fXDbVztcfE94UmN88&head=example:moderation-charters&network=devnet&devnet=moutai:config.readonly: false → ∅, each refused with 40002.Testing
npm test: 78 tests pass. They include:ttl, an added index, an added rule, a loweredmaxBytes, a changedrefersTo, a removed property, a removed document type, a required property withoutrequiredSince, a new type with a wrongrequiredSince, a moderation list change and a skipped version;npm run typecheck,npm run build,npm run validate:examples: clean./contract-visualizer/, runs a PR comparison without downloading the SDK.?url=: GitHub commit and branch links (a slash in the ref) through the dev server and the production build; a 404 and a host without CORS show their messages.Notes
DataContract::validate_updatein rs-dpp. Exposing it in the wasm SDK (asDataContract.validateUpdate(newContract, platformVersion)or similar) would let this panel show the platform's own answer; that is a separate platform change.🤖 Generated with Claude Code