Skip to content

feat(gnovm/lint): enforce last elem of pkg path to match pkg name#5048

Open
MikaelVallenet wants to merge 30 commits intognolang:masterfrom
MikaelVallenet:feat/gnovm/add-pkg-match-pkg-name-with-last-elem-import-path
Open

feat(gnovm/lint): enforce last elem of pkg path to match pkg name#5048
MikaelVallenet wants to merge 30 commits intognolang:masterfrom
MikaelVallenet:feat/gnovm/add-pkg-match-pkg-name-with-last-elem-import-path

Conversation

@MikaelVallenet
Copy link
Member

@MikaelVallenet MikaelVallenet commented Jan 13, 2026

Description

Closes #1571

Enforces that package names must match the last element of their import path, following Go conventions.

BREAKING CHANGE: Packages with names that don't match their path's last element will be rejected on deployment.
Existing on-chain packages are unaffected, but new deployments must comply. For example, deploying a package foo at
path gno.land/r/demo/bar will now fail.

Changes

Core validation (gnovm/pkg/gnolang/mempackage.go):

  • LastPathElement() - extracts the last meaningful path element, skipping version suffixes
  • ValidatePkgNameMatchesPath() - ensures package name matches path element
  • Version suffixes (v1, v2, v3, ...) are recognized and skipped when matching

Note on v1: Go module convention states that v1 should not appear in import paths. However, I allowed v1 as
a version suffix for backwards compatibility with existing packages like gno.land/r/gnoland/boards2/v1 and
gno.land/r/sys/users/v1.

Enforcement:

  • ValidateMemPackageAny() enforces the check for MPUserAll packages (on-chain deployment paths: keeper
    AddPackage and genesis loading)
  • gno lint warns about mismatches before deployment
  • Filetests validate name-path matching via ValidatePkgNameMatchesPath in the filetest runner
  • Filetest package name is now derived from file content (MustPackageNameFromFileBody) instead of from the path

Example package renames:

  • gnoblogblog
  • gnopagespages
  • foo20grc20factory
  • evalmath_eval
  • todolistrealmtodolist
  • emiteventsevents
  • image_embedimg_embed
  • testsvm (r/tests/vm)
  • mapdeletemap_delete
  • nir1218_evaluation_proposal → moved to subfolder /evaluation

Examples

Path Package Valid
gno.land/r/demo/counter counter
gno.land/r/demo/counter foo
gno.land/r/demo/foo/v2 foo
gno.land/r/demo/foo/v1 foo
Contributors' checklist
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests

@github-actions github-actions bot added 📖 documentation Improvements or additions to documentation 🧾 package/realm Tag used for new Realms or Packages. 📦 🤖 gnovm Issues or PRs gnovm related 📦 ⛰️ gno.land Issues or PRs gno.land package related labels Jan 13, 2026
@Gno2D2 Gno2D2 requested a review from a team January 13, 2026 17:48
@Gno2D2
Copy link
Collaborator

Gno2D2 commented Jan 13, 2026

🛠 PR Checks Summary

🔴 Changes related to gnoweb must be reviewed by its codeowners

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
Read More

🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers.

✅ Automated Checks (for Contributors):

🟢 Maintainers must be able to edit this pull request (more info)
🔴 Changes related to gnoweb must be reviewed by its codeowners
🟢 Pending initial approval by a review team member, or review from tech-staff

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 The pull request was created from a fork (head branch repo: MikaelVallenet/gno)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Changes related to gnoweb must be reviewed by its codeowners

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 A changed file matches this pattern: ^gno.land/pkg/gnoweb/ (filename: gno.land/pkg/gnoweb/handler_http.go)

Then

🔴 Requirement not satisfied
└── 🔴 Or
    ├── 🔴 Or
    │   ├── 🔴 And
    │   │   ├── 🔴 Pull request author is user: alexiscolin
    │   │   └── 🔴 This user reviewed pull request: gfanton (with state "APPROVED")
    │   └── 🔴 And
    │       ├── 🔴 Pull request author is user: gfanton
    │       └── 🔴 This user reviewed pull request: alexiscolin (with state "APPROVED")
    └── 🔴 And
        ├── 🟢 Not (🔴 Pull request author is user: alexiscolin)
        ├── 🟢 Not (🔴 Pull request author is user: gfanton)
        └── 🔴 Or
            ├── 🔴 This user reviewed pull request: alexiscolin (with state "APPROVED")
            └── 🔴 This user reviewed pull request: gfanton (with state "APPROVED")

Pending initial approval by a review team member, or review from tech-staff

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 Not (🔴 Pull request author is a member of the team: tech-staff)

Then

🟢 Requirement satisfied
└── 🟢 If
    ├── 🟢 Condition
    │   └── 🟢 Or
    │       ├── 🟢 User jefft0 already reviewed PR 5048 with state APPROVED
    │       ├── 🟢 At least 1 user(s) of the team tech-staff reviewed pull request
    │       └── 🔴 This pull request is a draft
    └── 🟢 Then
        └── 🟢 Not (🔴 This label is applied to pull request: review/triage-pending)

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission

@codecov
Copy link

codecov bot commented Jan 13, 2026

Codecov Report

❌ Patch coverage is 86.84211% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
gnovm/pkg/gnolang/mempackage.go 78.26% 3 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@MikaelVallenet MikaelVallenet marked this pull request as ready for review January 13, 2026 18:13
@Gno2D2 Gno2D2 added the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Jan 13, 2026
@davd-gzl
Copy link
Member

davd-gzl commented Jan 14, 2026

Note: If this is merged we should create an issue on the LSP of Gno about this new feature.

Copy link
Member

@davd-gzl davd-gzl left a comment

Choose a reason for hiding this comment

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

Image Image

LGTM

@jefft0 jefft0 added this to the ⏭️Next after mainnet beta milestone Jan 28, 2026
Copy link
Contributor

@jefft0 jefft0 left a comment

Choose a reason for hiding this comment

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

This PR fixes a "Next after mainnet beta" milestone issue. The docs are updated. The breaking change is documented. Includes tests and changes to existing package names to comply. CI checks pass. Ready for core devs to review and decide if and when the breaking changes is wanted.

@Gno2D2 Gno2D2 removed the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Feb 3, 2026
@jefft0 jefft0 moved this to Other dev assigned in 🤝🏻 Partner: Berty Feb 4, 2026
Copy link
Member

@thehowl thehowl left a comment

Choose a reason for hiding this comment

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

Generally LGTM.

@MikaelVallenet MikaelVallenet force-pushed the feat/gnovm/add-pkg-match-pkg-name-with-last-elem-import-path branch from d74e921 to a96ae91 Compare February 24, 2026 11:19
@MikaelVallenet
Copy link
Member Author

with latest changes, we could say that v0 are not audited / safe version and display warning for end users when using v0 realms or using a realm that depends on v0 realms objects or import

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📖 documentation Improvements or additions to documentation 🛠️ gnodev 🌍 gnoweb Issues & PRs related to gnoweb and render 📦 ⛰️ gno.land Issues or PRs gno.land package related 📦 🤖 gnovm Issues or PRs gnovm related 🧾 package/realm Tag used for new Realms or Packages.

Projects

Status: In Progress
Status: Other dev assigned

Development

Successfully merging this pull request may close these issues.

rfc: enforce package name == last element of import path in maketx addpkg

7 participants