Skip to content

feat(rules): add Move review rules - #959

Merged
lizhengfeng101 merged 4 commits into
alibaba:mainfrom
chethanuk:wf/move-language-support
Nov 16, 2026
Merged

lizhengfeng101 merged 4 commits into
alibaba:mainfrom
chethanuk:wf/move-language-support

Conversation

@chethanuk

Copy link
Copy Markdown
Contributor

Description

.move files were never reviewed. The extension is missing from supported_file_types.json, so IsAllowedExt drops them at the filter gate before any rule can run. Move.toml was already reachable (.toml is allowlisted) but fell through to the generic default.md.

This adds .move to the allowlist and registers two rule docs in path_rule_map: **/*.move → move.md for source, **/Move.toml → move_toml.md for the package manifest. The manifest gets its own short doc for the same reason cargo_toml.md and pom_xml.md do — what goes wrong there (git deps pinned to rev = "main", named addresses changed in place on a published package, dep-replacements drifting between testnet and mainnet) has nothing to do with the source-level checks. Data only, no Go source changes.

The four exclude patterns are scoped by extension (**/build/**/*.move, not a bare **/build/**). IsExcludedPath applies every pattern to every path with no language dispatch, so an unscoped build/ pattern would also drop Java, Gradle, TypeScript and CMake output. That is why the file already carries **/Tests/**/*.swift and **/tests/**/*.nim rather than the directory alone. Three negative rows in TestIsExcludedPath fail if anyone broadens it later.

Both *_test.move and *_tests.move are excluded. The singular is as common as the plural in Move and usually sits in sources/ next to the code rather than under tests/, where the directory pattern never reaches it.

Limitation

.move diffs that used to be skipped are now reviewed. Anyone who does not want that opts out with user exclude globs, which are checked before the allowlist.

Type of Change

  • New feature (non-breaking change that adds functionality)

How Has This Been Tested?

  • make test passes locally
  • Manual testing (describe below)

Rows appended to the existing table tests, plus one new test:

  • TestIsAllowedExt — .move and .MOVE.
  • TestIsExcludedPath — the four new patterns, plus three negatives (frontend/build/index.ts, build/classes/com/example/Foo.java, build/main.go) that fail if the build/ pattern loses its extension scope.
  • TestResolve_DefaultRules — source and manifest paths resolve by heading anchors unique to each doc.
  • TestResolveDetail_SystemMoveTomlPatternPrecedesMove (new) — pins Move.toml to the **/Move.toml pattern, including the uppercase spelling.

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable)
  • I have signed the CLA

The rule table in pages/src/content/docs/{en,ja,ru,zh}/review-rules.md lists both new patterns.

Related Issues

Part of #470.

@github-actions

Copy link
Copy Markdown
Contributor

✅ OpenCodeReview: Review complete: 0 finding(s) across 3 selected item(s).

@chethanuk
chethanuk force-pushed the wf/move-language-support branch 2 times, most recently from 72dc259 to 7af2b97 Compare August 17, 2026 07:35

@wu21-web wu21-web left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest putting **/*.move and **/Move.toml together in the site documentation for readability, but it is a minor issue. LGTM.

@chethanuk
chethanuk force-pushed the wf/move-language-support branch 2 times, most recently from 1ecd1b1 to 7a0f081 Compare August 18, 2026 08:47
@chethanuk

Copy link
Copy Markdown
Contributor Author

@lizhengfeng101 Please review and merge this. Future main updates might cause more conflicts. I resolved conflicts 3 times now... Thanks :)

@chethanuk
chethanuk force-pushed the wf/move-language-support branch from 7a0f081 to 8015655 Compare August 21, 2026 06:04
@chethanuk

Copy link
Copy Markdown
Contributor Author

@lizhengfeng101 Rebased onto main and conflicts resolved. Please review and merge this. Thanks :)

@chethanuk

Copy link
Copy Markdown
Contributor Author

@lizhengfeng101 Rebased onto main and conflicts resolved again. Please review this. Thanks :)

@lizhengfeng101

Copy link
Copy Markdown
Contributor

Thanks for the contribution! The rule doc is well-structured and the test coverage looks solid.

Since Move is still a relatively niche language, I'd prefer to hold off on merging for now and wait for community members who actively develop in Move (or language experts) to review the rule doc for accuracy. Smart contract review rules carry high stakes — an incorrect rule could either produce false positives or, worse, miss real vulnerabilities.

I'll leave this open and revisit once we get domain-expert feedback.

@Qiyuanqiii Qiyuanqiii left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the thorough implementation. I reviewed the proposed default rule documents against the official Move, Sui, and Aptos documentation. The allowlist, routing, and test work looks solid, but several statements in move.md and move_toml.md currently contradict documented platform semantics or restate compiler-enforced checks as review findings. Because these documents would be injected as the defaults for every Move review, those statements would create systematic false positives.

I am requesting changes only for the seven concrete accuracy and platform-gating issues called out inline. Please revise or remove those rules while preserving the useful Sui/Aptos/core-Move distinction already established by the document.

This is an evidence-based documentation review. I am not presenting it as a substitute for the active Move-developer review requested by the maintainer.

@@ -0,0 +1,18 @@
#### Move Package Manifest Hygiene
- Git dependencies pinned to a branch or moving tag rather than a full commit hash: `rev = "main"`, `rev = "mainnet"`, and `rev = "framework/testnet"` all resolve differently over time, so the bytecode published today may not be the bytecode published tomorrow

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would flag official manifests. The Move Reference explicitly allows rev to be a branch, tag, or commit, and explains that a committed Move.lock records fixed dependency revisions for reproducible builds. The official Aptos package example itself uses rev = "mainnet".

Please narrow this to evidence that resolution is not fixed - for example, a missing or uncommitted lockfile, or an unexpected Move.lock resolution change - rather than treating a branch or tag as a defect by itself.

Sources: Move package reference | Aptos package guide

- `local =` paths that are absolute or reach outside the repository, which do not resolve on another machine or in CI
- Dependencies added to `[dependencies]` when they are only used by tests, which publishes them as part of the package

#### Addresses and Publication

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"_" is a documented named-address parameter, not inherently an invalid publication address. The Move package reference shows that it can be instantiated by a dependent package, and the official Aptos create-package example deliberately declares hello_blockchain = "_".

Please flag this only when the effective build or publish inputs leave a required address unresolved or resolve it to the wrong address, rather than flagging the placeholder itself.

Sources: Move package reference | Aptos package guide


#### Addresses and Publication
- `[addresses]` entries left as the `"_"` placeholder in a package that is meant to be published, which fails or resolves to an unintended address
- Named addresses changed in place for an already-published package, silently retargeting every reference

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documented package semantics do not allow these sections to silently leak into an ordinary build: [dev-dependencies] and [dev-addresses] are included only in dev/test modes.

Please remove this rule or require concrete evidence that the project build explicitly enables a dev/test mode (or uses nonstandard tooling with different semantics).

Source: Move package manifest reference

- `acquires` annotations that no longer reflect the resources a function reaches after the change
- Aborts raised with a bare integer where the module otherwise uses categorized `error::` constructors, losing the client-visible error category

#### Object Model and Sharing (Sui)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This describes a successful Owned -> Shared conversion, but Sui documents the opposite behavior: only an object created in the same transaction can be shared, and attempting to share an already-owned object aborts with ESharedNonNewObject.

Please rewrite this as a reachable-abort check when a pre-existing owned object can reach share_object. Whether a newly created object should be shared is a separate authorization/design question and needs evidence from the intended access policy.

Source: Sui storage functions - Share

- `transfer::transfer` versus `transfer::public_transfer` chosen inconsistently with the type's `store` ability and the custody the caller expects
- A value sent to `ctx.sender()` where returning it to the caller would compose better and keeps the PTB in control of its destination (`self_transfer`)
- Wrapping a shared or frozen object inside another object, which strands it (`freeze_wrapped`)
- `&TxContext` on a public function that will need mutation later, forcing a breaking signature change (`prefer_mut_tx_context`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revise both this rule and the earlier generic underlying-id rule. The id: UID layout is an additional Sui-verifier requirement, not a generic key rule, so the first half is compiler-enforced on Sui and does not apply to Aptos/core Move. Even on Sui, retaining a UID after destroying the containing object can be intentional (the documented proof-of-deletion pattern), so unconditional id.delete() is not always required.

A higher-confidence lifecycle check is deleting a parent UID before removing its dynamic fields or received children, which can leave state permanently inaccessible.

Sources: Move abilities reference | Sui key ability | Sui UID lifecycle | Sui dynamic fields

- Wrapping a shared or frozen object inside another object, which strands it (`freeze_wrapped`)
- `&TxContext` on a public function that will need mutation later, forcing a breaking signature change (`prefer_mut_tx_context`)
- A `key` struct whose first field is not `id: UID`, or a destroy path that does not call `id.delete()`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For current Sui Move, public is already transaction-callable and adding entry gives the function no additional permissions or restrictions. That is why the compiler reports public_entry as an unnecessary-modifier lint; it does not by itself widen the callable surface.

Please remove this as a security finding or platform-qualify it around a concrete authorization/composability defect rather than the modifier alone.

Sources: Sui visibility modifiers | Sui lint reference

Comment thread internal/config/rules/rule_docs/move.md Outdated
- Named `const E*` abort code values changed or renumbered: clients and indexers match on them, so a renumbering is a breaking change even though the code still compiles
- State changes that indexers depend on made without emitting the corresponding event, or an event's fields changed in place
- Struct fields or public function signatures changed in ways that violate Sui upgrade compatibility or Aptos `upgrade_policy = "compatible"`
- `#[test_only]` mint, admin, or fixture functions reachable from a non-test build, or test-only imports leaking into published bytecode

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under the documented Sui compilation model, #[test_only] items are compiled only in test mode and are excluded from normal builds. Artifacts built with any mode enabled, including test mode, are explicitly non-publishable. Therefore these items cannot normally leak into published bytecode.

Please remove this rule or gate it on evidence that a nonstandard toolchain bypasses the documented compile-time and publishability checks.

Sources: Sui compilation modes | Move unit-testing reference

@Qiyuanqiii

Copy link
Copy Markdown
Contributor

While I’ve put forward this change proposal, it is no substitute for a proper review from Move community developers. As @lizhengfeng101 noted, Move is still a relatively niche language. My knowledge of it only comes from what I picked up incidentally while learning Rust — after all, Move’s ownership model draws inspiration from Rust, and the core Move VM is also implemented in Rust.

That said, I have no hands-on experience building with Move. It’s a purpose-built language for virtual machines, primarily used for digital tokens and financial-related scenarios. I haven’t worked with it extensively, so this will need further review from someone with deep expertise in the language.

@wu21-web

Copy link
Copy Markdown
Contributor

@chethanuk HEADS UP: If no activity occurs on this pull, I will closed this as superseded by #1829

@Qiyuanqiii

Copy link
Copy Markdown
Contributor

@chethanuk HEADS UP: If no activity occurs on this pull, I will closed this as superseded by #1829

So the author of this new PR clearly does not meet the criteria for active Move developers mentioned by lizhengfeng… In my opinion, this is quite rough

@wu21-web

Copy link
Copy Markdown
Contributor

@Qiyuanqiii Quality is the only standard.

Move source files were not reviewed: `.move` was absent from the extension
allowlist, so both filter call sites dropped them at the `IsAllowedExt` gate
before any rule could run. `Move.toml` was already reachable (`.toml` is
allowlisted) but fell through to `default.md`.

Adds `.move` to the allowlist, four Move-scoped exclude patterns, and two
rule docs wired into `path_rule_map`: `move.md` for source and `move_toml.md`
for the manifest, following the existing `cargo_toml.md` split. Data only, no
Go source changes.

The exclude patterns are scoped by extension (`**/build/**/*.move`, not a bare
`**/build/**`) because `IsExcludedPath` applies every pattern to every path
with no language dispatch; an unscoped `build/` pattern would also drop Java,
Gradle, TypeScript and CMake output. Three negative rows in `TestIsExcludedPath`
pin that down and fail if the pattern is broadened.

Both `*_test.move` and `*_tests.move` are excluded. The singular is as common
as the plural and frequently sits in `sources/` rather than `tests/` (e.g.
aptos-core's `move-examples/hello_blockchain/sources/hello_blockchain_test.move`),
where neither the `tests/` nor the plural pattern reaches it. This mirrors the
singular/plural pairs the file already carries for Java and Swift.

Behaviour change: `.move` diffs that were previously skipped are now reviewed.
Users opt out via user exclude globs, which are checked before the allowlist.

Evidence: `go test -race ./...` passes; `TestResolve_DefaultRules` resolves
`.move` to move.md and `Move.toml` to move_toml.md via unique heading anchors.
Several rules flagged documented, valid Move patterns: branch revs that
Move.lock pins, the "_" address placeholder, dev-only manifest sections,
and #[test_only] items that never reach published bytecode. Others
described behaviour Sui rejects (sharing an owned object aborts) or
restated compiler checks (id: UID layout, public entry on Sui).

Narrow or replace each one and gate the platform-specific ones to Sui or
Aptos. The Move.toml precedence test now anchors on Move.lock, since the
rev = "main" example is gone.

Signed-off-by: ChethanUK <[email protected]>
…ources

Drop bullets the compiler or upgrade check already rejects (acquires,
overlapping borrows, struct/signature upgrade changes, weakened
upgrade_policy), fix the transfer, freeze_wrapped, entry and dev-dependencies
claims, add Sui version-gating after upgrade, and exempt #[test_only].
Add nested-package exclusion test rows.

Signed-off-by: ChethanUK <[email protected]>
@chethanuk
chethanuk force-pushed the wf/move-language-support branch from 04be87d to a03f607 Compare November 11, 2026 07:44
@lizhengfeng101

Copy link
Copy Markdown
Contributor

Two concrete follow-ups from reviewing head a03f607a9f36cffed2a6b934410d7a57b3ef4831:

1. Required correction: distinguish valid Sui environment overrides from actual mismatches

In move_toml.md, lines 12–13, a different rev in dep-replacements is treated as evidence that source typechecking and on-chain linkage disagree. A replacement changes the effective source dependency for the selected environment, not just its on-chain linkage. Sui's dependency-combination implementation explicitly selects replacement.dependency.unwrap_or(default).

For example, the default dependency can use commit A while the mainnet replacement uses commit B and points to the mainnet package published from B. That difference alone is not a bug. Likewise, independently deployed testnet and mainnet packages can legitimately have different IDs.

Please revise these checks to require evidence of a mismatch between the effective dependency and publication data within the selected environment, rather than differences between defaults and overrides or between networks. Otherwise, valid multi-environment configurations become false-positive targets.

2. Verification: supplement routing tests with focused semantic checks

The added tests establish extension filtering and rule routing, but heading/pattern assertions cannot validate the Move-specific advice. Please add or record a small Sui/Aptos review sanity check, identifying the toolchain versions and including:

  • A valid environment override like the example above, which must not be flagged solely for differing revisions or network IDs.
  • A demonstrated source/publication mismatch within the selected environment, which the corrected rule should still identify.
  • A check that dialect-specific advice is applied only to the relevant dialect.

A short recorded smoke test is sufficient for this targeted validation; this is not a request for a full blockchain benchmark. It would complement, not replace, the domain-expert review already requested in this thread. Please also rerun the affected tests with make test and confirm the required CI checks pass after the revision.

For transparency, the supporting OCR run completed with zero findings across three selected items; that result does not establish coverage or correctness of the new rule prose.


AI disclosure: This feedback was prepared with Codex; OpenCodeReview (ocr) was also used during the review.

@lizhengfeng101

Copy link
Copy Markdown
Contributor

Hi @chethanuk, a quick follow-up on the two items above: any update on the Sui environment-override rule correction and the small Sui/Aptos sanity check? Please let us know if you are blocked on either item. Thanks!

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lizhengfeng101
lizhengfeng101 merged commit 8441fa7 into alibaba:main Nov 16, 2026
14 checks passed
@wu21-web

Copy link
Copy Markdown
Contributor

Thanks this looks great too with the requested changes!

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.

4 participants