const MaxNameLen, MaxVersionLen, MaxPkgPathLen, MaxURLLen, MaxNotesLen, MaxReasonLen, MaxDescriptionLen
Size caps. A registry is written by anyone who opens a project in it, so every caller-supplied string has a ceiling.
gno.land/p/moul/releases/v0A project's changelog, and the answer every version of it needs: am I the
latest, and if not, what am I still allowed to do? A revival of the
quarantined p/demo/releases from gnolang/gno, extended with a status per
version, a pause policy, and the banner an old version prepends to its page.
The state lives in r/moul/releases, which is
also the live demo: one Project per name, each served as a stage homepage.
| status | stored | writes | banner |
|---|---|---|---|
| 📝 draft | yes | allowed | "a draft" |
| 🧪 prerelease | yes | allowed | "a prerelease" |
| ✅ supported | yes | allowed | "still supported, the latest is ..." |
| 🌟 latest | computed | allowed | none |
| ⚠️ deprecated | yes | allowed until its sunset height, read-only from it | "deprecated, read-only from block N" |
| 🚫 yanked | yes, final | paused | "yanked, it accepts nothing" |
| 🔴 vulnerable | yes, can only be yanked | paused | "vulnerable, it accepts nothing" |
Latest is the most recently added Supported release, computed on read, so
shipping v2 never means rewriting v1. Severity() orders statuses by how much
a reader should worry, Latest 0 to Vulnerable 5.
Policy(release, height) returns a p/moul/pausable State. It is a pure
function of the stored status and the block height, so a deprecated version
goes read-only at its sunset block with no transaction from anyone. An
unknown status fails closed (paused); an unlisted path is running, because a
registry that paused what it had not heard of would let a typo take a realm
down.
p, _ := releases.NewProject("config", "moul's shared settings")
p.Add("v0", "gno.land/r/moul/config/v0", "", "first cut", releases.Supported, height)
p.Add("v1", "gno.land/r/moul/config/v1", "", "- pause levels", releases.Supported, height)
p.Deprecate("v0", "use v1", height+100000) // read-only from that block
p.Yank("v0", "leaks keys") // final
p.Latest() // Release{Version: "v1", ...}, true
p.ByVersion("v0"), p.ByPath("gno.land/r/moul/config/v0")
p.State(path, height) // pausable.State
p.AssertWritable(path, height)
p.Banner(path, height, stageURL) // "" for the latest
p.RenderStage(height, linkFn), p.RenderRelease("v0", height)
Lookups return a Release by value. The original ByVersion returned a
pointer to a range-loop copy, which looked like a handle on the stored release
and was not; there is no pointer here to get wrong. Storage is two
p/nt/bptree indexes (version, package path) plus the insertion order.
Every owner-typed string (description, notes, reason, URL) is escaped where the markdown is built, because the registry is public and anyone can open a project in it.
A version already on chain is immutable: it cannot gain the import. It can only be listed and labelled here, and its stage page and the newer versions say it is old. Only versions written after this package can show the banner and pause themselves.
Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.
Dependency graph:

⚠️ Disclaimer: provided as-is, without warranty; not security-audited. Full disclaimer: DISCLAIMER.
Size caps. A registry is written by anyone who opens a project in it, so every caller-supplied string has a ceiling.
1const (
2 // Draft is listed but not announced: the code may not be on chain yet.
3 Draft Status = iota
4 // Prerelease is on chain and usable, with no promise attached.
5 Prerelease
6 // Supported is a release its owner still answers for.
7 Supported
8 // Latest is the newest Supported release. Computed, never stored.
9 Latest
10 // Deprecated still works, says so, and goes read-only at its sunset.
11 Deprecated
12 // Yanked was withdrawn: it stays listed, because a version that existed
13 // cannot un-exist, and every write is refused.
14 Yanked
15 // Vulnerable has a known flaw: it stays listed and everything is refused.
16 Vulnerable
17) 1var (
2 ErrInvalidName = errors.New("releases: invalid project name")
3 ErrInvalidVersion = errors.New("releases: invalid version")
4 ErrInvalidPkgPath = errors.New("releases: invalid package path")
5 ErrInvalidText = errors.New("releases: text too long or not printable")
6 ErrInvalidStatus = errors.New("releases: status cannot be stored")
7 ErrInvalidSunset = errors.New("releases: sunset height must not be negative")
8 ErrVersionExists = errors.New("releases: version already released")
9 ErrPathExists = errors.New("releases: package path already listed")
10 ErrNotFound = errors.New("releases: no such version")
11 ErrFinal = errors.New("releases: a yanked release cannot change status")
12 ErrVulnerableIsFinal = errors.New("releases: a vulnerable release can only be yanked")
13)Policy is what a release's status means for the realm that is that release, at block height `height`, as a p/moul/pausable State:
1Draft, Prerelease, Supported, Latest running
2Deprecated running until its sunset, read-only from it
3Yanked, Vulnerable paused
It is a pure function of the stored status and the height, so a deprecated version goes read-only at its sunset block with no transaction from anyone. An unknown status fails closed, like pausable.MustParse.
ValidName reports whether s can name a project: a lower-case letter, then letters, digits and dashes. It is the realm's render path, so it is kept to characters that need no escaping anywhere.
ValidPkgPath reports whether s looks like a gno.land package path. It does not ask the chain whether the package exists: a Draft is listed before its code is.
ValidVersion reports whether s can be a version. Not semver-enforcing, for the reason p/moul/forge gives: gno.land versions as v0, v1 with no minor or patch, and a registry refusing those would refuse its own ecosystem.
NewProject opens an empty changelog.
ParseStatus reads a status word, case-insensitively. ok is false for anything else, "latest" included, since a stored Latest would lie the moment a newer release ships.
Project is a changelog: the releases of one thing, in the order they were listed, each findable by version and by package path.
It holds no owner. Who may write is the storing realm's question, and the library stays usable by a realm with one owner, a DAO, or none.
1func (p *Project) Add(version, pkgPath, url, notes string, status Status, height int64) errorAdd lists a release. Version and package path are both keys and neither can be listed twice: a version that pointed at different code later would be a lie told to everyone who pinned it.
AssertWritable aborts unless the release at pkgPath may still be written to at this height. A version puts it at the top of every state-changing function.
Banner is the markdown a release prepends to its own Render, or "" when it is the Latest or not listed at all. It ends in a blank line, so
1return reg.Banner(self) + body
is the whole integration. stage is the link to the project's stage page, or "" to leave it out.
ByPath returns a copy of the release published at pkgPath.
ByVersion returns a copy of the release listed under version.
Deprecate marks a release deprecated. It keeps working, with a banner, until block height sunset, and is read-only from then on. sunset 0 means never.
IsLatest reports whether pkgPath is this project's Latest.
Latest is the most recently added Supported release. Order of addition, not version order, decides: versions here need not be semver, and an owner who lists v2 before backfilling v1 meant v2.
Releases returns copies of every release, newest first.
RenderRelease is one version's page: its status, what that means for writes at this height, where it lives, and its notes.
RenderStage is the project's homepage: the latest release up front, every version with its status, then the changelog, newest first. link turns a version into the URL of its RenderRelease page, or is nil for none.
SetDescription replaces the one-line description.
SetStatus moves a release to any storable status, with the reason readers will see. A yanked release is final, and a vulnerable one can only be yanked: neither can be made safe again, because its code cannot change. Setting Deprecated this way clears any sunset; Deprecate sets one.
SetSuccessor points readers of version at successor instead of at Latest, for a line that forked. An empty successor clears it.
State is Policy for the release published at pkgPath. A path this project does not list is running: being unlisted is not a reason to stop, and a registry that paused whatever it had not heard of would let a typo take a realm down.
StatusOf is the status a reader sees: the stored one, with Supported promoted to Latest for the one release it applies to.
Yank withdraws a release. It stays listed; every write to it is refused.
1type Release struct {
2 Version string // "v1", the key inside its project
3 PkgPath string // "gno.land/r/moul/config/v1", unique inside its project
4 URL string // optional link; the realm itself when empty
5 Notes string // the changelog entry, one item per line
6 Status Status // the stored status; Latest is never stored
7 Reason string // why the status is what it is, shown in banners
8 ReleasedAt int64 // block height at which it was listed
9 Sunset int64 // Deprecated only: the height it goes read-only, 0 for never
10 Successor string // optional version to send readers to instead of Latest
11}Release is one version of a project: the package path it was published at, what changed, and where it stands.
Project hands Releases out by value, so a caller holding one cannot change the registry by writing to it. The quarantined p/demo/releases this package revives returned a pointer to a range-loop copy from ByVersion, which looked like a handle on the stored release and was not; there is no pointer here to get wrong.
Status is where a release stands. It is stored on the release, except Latest, which is computed: the newest Supported release of a project is its Latest, and storing that would mean rewriting the previous one every time a new version ships.
Emoji is the one-glyph form a table shows in front of the word.
Label is the emoji and the word together, "⚠️ deprecated".
Severity is 0 for Latest and grows with how much a reader should worry: Supported 1, Draft and Prerelease 2, Deprecated 3, Yanked 4, Vulnerable 5.
Storable reports whether an owner may set this status. Latest is refused, since it is derived from the others.
String is the lower-case word, the same one ParseStatus reads back.