Skip to content

fix(basedao,daokit,daocond): settle the exported surface before it freezes - #70

Merged
zxxma merged 5 commits into
feat/topaz-v2-renamefrom
freeze/exported-surface
Jul 20, 2026
Merged

zxxma merged 5 commits into
feat/topaz-v2-renamefrom
freeze/exported-surface

Conversation

@zxxma

@zxxma zxxma commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #69. Everything here is fixable now and never again — publication is immutable.

Takes #66, minus its one blocker

AddMember("") guard and its tests, committed under David's authorship.

Rejected: #66's change to New(). It replaced Realm: unsafe.CurrentRealm() with runtime.NewRealm(rlm.Address(), rlm.PkgPath()), which lets whoever calls New() decide the identity the DAO will later require of itself. gno's own stdlib says of that constructor, verbatim: "Callers should NOT use this to fabricate realm-context for authorization — a constructed Realm is just a (addr, pkgPath) tuple and carries no runtime-validated authority."

Three permanent mistakes in the surface

MembersViewExtensionPath Named gno.land/p/demo/basedao, a package that does not exist. It is the extension registry key — third-party lookups get pinned to it.
daocond.VoteYes/No/Abstain Untyped strings despite type Vote string. An untyped constant assigns to a plain string without complaint, so typing them later breaks any caller that stored one. Breaks exactly one call site here.
Proposal.ExecutorID Exported, written by nothing, anywhere. Execute computes the value and discards it; writing it would need Core.Execute's equally-frozen signature. Removed — shipping it guarantees it reads "" forever.

Verified no consumer depends on the extension key, registration and lookup both read the same constant, and r/samcrew is empty on topaz-1 so no on-chain state is keyed to the old path.

Empty role names

Symmetric with the member-id guard, and sharper: role names are substituted into rendered prose with strings.ReplaceAll, and an empty needle matches between every character. Measured: "hello world", 11 characters, came back as 227. The members table has the same pattern and an empty role reaches it through the ordinary API — AddRoleToMember succeeds once "" is in Roles. Measured there: 585 → 2578.

Guarded at AddRole, and both render loops skip an empty role, because Roles is an exported avl.Tree that can be seeded around the guard.

The docs, which ship with the frozen package

Every Propose/Vote example was missing its threaded realm. Both "Complete Example" realms omitted GetProfileString, which New() hard-panics without — the canonical copy-paste deployed a realm that panicked at init. daocond's README documented Vote as an int enum with iota. Identifiers that never existed: store.RoleCount, daocond.NewRoleCount, an extension lookup type-asserting *ExtensionInfo to an interface.

The example realms exported their handle as DAO. That is the precondition for the whole donation class #69 closes, so it is unexported now with the reason stated — #64's correction, carried over as intent since its call forms predate the realm threading.

Both Complete Examples are now checked in under gno/r/readme_*_example, compiled by CI with their init actually run, and a script re-extracts each block from the markdown and diffs it against its fixture so they cannot drift apart. Negative-controlled: it refuses a deliberate perturbation.

Verification

10 packages ok · lint clean · fmt -diff clean · zero gno: downloading · deployer assert_gnodaokit_source_form topaz-1 passes.

Every guard mutation-checked: dropping the member-id guard, the role-name guard, or either render skip fails exactly its own test.

Independently reviewed in an isolated worktree; that review found the GetProfileString brick, the daocond README, and the incomplete role fix, all of which are addressed here.

davd-gzl and others added 5 commits July 20, 2026 17:34
"" is what CallerID resolves to when it cannot name the caller, so it must
never become a member id. Guard it at AddMember, where every membership write
that goes through the store passes.

Also documents the crossing-function form for cross-realm membership gating.

Taken from #66, minus its change to New(): d.Realm must stay
unsafe.CurrentRealm(). A caller-supplied realm lets whoever calls New() decide
the identity the DAO will later require of itself, and gno's own stdlib says of
runtime.NewRealm: "Callers should NOT use this to fabricate realm-context for
authorization — a constructed Realm is just a (addr, pkgPath) tuple and carries
no runtime-validated authority."
…xported surface

Each of these is fixable now and never again.

MembersViewExtensionPath named gno.land/p/demo/basedao, a package that does not
exist; this one is published at gno.land/p/samcrew/basedao. It is the extension
registry key, so third-party lookups would be pinned to the wrong literal
forever.

daocond's vote constants were untyped despite Vote existing. An untyped constant
assigns to a plain string without complaint, so typing them later would break
any caller that had stored one — it has to happen before publication. It breaks
exactly one call site here, a txlink.Call that wants a string, and removes a
conversion of a value that already had the right type.

Proposal.ExecutorID was exported and never written by anything. Execute computes
exactly that value and discards it, but writing it would need Core.Execute's
signature, which is equally frozen and which the demo realms call directly.
Removing the field is the honest option: shipping it guarantees it reads "" in
every serialized proposal forever.
The READMEs ship with the package, so a wrong example is as permanent as a wrong
signature.

Propose and Vote lost their threaded realm in every example. The DAO interface
listing, the basedao governance section, the quickstart realms and the
InstantExecute example all showed forms that no longer compile.

The example realms exported their DAO handle as `DAO`. Anything that can reach
that value can call the entry points directly, bypassing the realm's own
crossing functions — it is the precondition for the whole donation class the
identity work just closed. Unexported, with the reason stated. (This is #64's
correction; its call forms predate the realm threading, so only the intent
carries over.)

The member-only example gated on `cur.Previous().Address()`. A member id is an
address for an account and a PKGPATH for a realm, so that silently locks out
every realm member. It also repeated the claim that a stack walk names the
outermost crossing realm: it does not, on any path the entry gate admits — it
names the immediate caller there too, and goes wrong only in the shape the gate
now rejects.

realmid's README taught `CallerID: realmid.Previous`, which no longer
type-checks, and taught the package as a caller-authentication tool. It is built
on the stack-walking primitives that basedao stopped using; the README now says
so and shows the threaded-realm form instead.

Also drops the last references to gno.land/p/demo/basedao.
…prose

Symmetric with the member-id guard, and for a sharper reason: an empty role name
is destructive rather than merely useless.

RenderWithRolesLinks substitutes role names into rendered prose with
strings.ReplaceAll, and an empty needle matches between every character.
Measured before the guard: "hello world", 11 characters, came back as 227 —
the link repeated between every letter. There is no way to remove a role from a
published DAO's render path afterwards.

Guarded at AddRole, which setRoles and NewMembersStore both go through. The
render loop also skips an empty role, because Roles is an exported avl.Tree that
a same-realm write or a MigrateFn can seed directly — the guard at the door is
not the only way in.
…t way

Review found the documentation shipping code that does not compile, which for a
package about to be published immutably is as permanent as a wrong signature.

Both "Complete Example" realms omitted GetProfileString, which New() hard-panics
without — anyone copy-pasting the canonical example deployed a realm that
panicked at init. basedao's copy also carried a botched identifier from the
previous docs pass, kept the realm-first Execute form its siblings had lost,
still assigned to a bare DAO in the migration sample, and called a Handle() the
sample realm never defined.

daocond's README documented Vote as an int enum with iota. It is a string type,
and typing its constants is exactly what the surrounding commit freezes — that
README was missed entirely.

Also corrects identifiers that never existed: store.RoleCount (it is
CountMembersWithRole), daocond.NewRoleCount (it is RoleCount), and an extension
lookup that type-asserted *ExtensionInfo to an interface.

The two Complete Example realms are now checked in under gno/r/readme_*_example
and compiled by CI, with their init actually run. A script re-extracts each
block from the markdown and diffs it against its fixture, so the two cannot
drift apart silently — verified against a deliberate perturbation, which it
refuses.

Also completes the empty-role fix: RenderMembersTable substitutes role names the
same way RenderWithRolesLinks does, and an empty role reaches it through the
ordinary API, since AddRoleToMember succeeds once "" is in Roles. Measured 585 ->
2578 characters without the skip, 585 -> 587 with it.

The guard script strips the fixture header in python rather than sed: the
range-with-block form differs between BSD and GNU, and it failed on the first
local run.
@zxxma
zxxma changed the base branch from fix/dao-caller-identity to feat/topaz-v2-rename July 20, 2026 18:49
@zxxma
zxxma merged commit 391e097 into feat/topaz-v2-rename Jul 20, 2026
5 checks passed
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.

2 participants