Skip to content

feat: republish fork at original paths for topaz-1: avl repoint + svg boundary (Q13 final form) - #65

Open
zxxma wants to merge 26 commits into
mainfrom
feat/topaz-v2-rename
Open

zxxma wants to merge 26 commits into
mainfrom
feat/topaz-v2-rename

Conversation

@zxxma

@zxxma zxxma commented Jul 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Supersedes #64 — carries its interrealm-v2 port (15dbc83) plus ONE commit adapting the fork to the launched topaz-1 genesis. This is the final form of Q13: the /v2 rename this PR previously carried is obsolete and has been stripped — the fork republishes at its ORIGINAL paths.

Genesis inspection (live topaz-1, rpc.topaz.testnets.gno.land)

  • vm/qpaths gno.land/p/samcrew → exactly {piechart, tablesort, urlfilter}. No p/samcrew/{daokit,basedao,daocond} in genesis — the path collision that motivated the /v2 rename never materialized (per feat: topaz testnet release candidate gnolang/gno#5945's curated 90-package set, now confirmed on the launched chain).
  • vm/qfile gno.land/p/demo/svg/svg.gno → p/demo/svg IS in genesis, imports gno.land/p/nt/avl/v0, and types Canvas.Style as *avl.Tree (the single-value-Get upstream avl) — so the svg-boundary alias is still required (proof below).

Stripped (vs the previous head 0612859)

  • 3 gnomod module renames (daocond|daokit|basedao → …/v2) — reverted.
  • 44 internal /v2 import repoints — reverted.
  • README /v2 examples (11 lines) — reverted.

Retained (the entire remaining diff: 7 files, +10/−9)

  • avl repoints ×8: p/nt/avl/v0 → p/samcrew/avl (×7) and …/v0/pager → p/samcrew/avl/pager (×1) — the vendored avl with two-value Get frozen. Zero call-site changes.
  • svg boundary (basedao/utils.gno, 2 lines): aliased ntavl "gno.land/p/nt/avl/v0" import + canvasStyle := ntavl.NewTree(). Re-verified required at chain/topaz: compiling without the alias fails with exactly
    • utils.gno:100: cannot use canvas[0].Style (*"gno.land/p/nt/avl/v0".Tree) as *"gno.land/p/samcrew/avl".Tree
    • utils.gno:114: cannot use canvasStyle (*"gno.land/p/samcrew/avl".Tree) as *"gno.land/p/nt/avl/v0".Tree

Fork logic remains byte-frozen vs #64 — path mechanics only.

Test plan

Toolchain built at tag chain/topaz (= fc4052651, the official release target commit and the launched chain's VM), with p/samcrew/avl{,/pager,/rotree} (samcrew-deployer deps/avl) and this branch's packages vendored into GNOROOT examples at their on-chain paths:

Package gno test . gno lint .
p/samcrew/realmid ? [no test files] clean
p/samcrew/daocond ok 0.85s clean
p/samcrew/daokit ok 0.80s clean
p/samcrew/basedao ok 0.98s clean
r/samcrew/daodemo/simple_dao ok 0.99s clean
r/samcrew/daodemo/custom_condition ok 1.00s clean
r/samcrew/daodemo/custom_resource ok 0.94s clean

gno fmt clean at the same ref (import groups re-sorted where the repoint changed ordering).

CI note (unchanged)

gno-test/gno-lint were already red on #64's head and stay red here for the same pre-existing reason: the Makefile pins gno 2c7f1abe, and at that pin gno lint/test auto-downloads current package sources that no longer compile under the pinned VM. Not introduced by this change — the branch is validated against the launched-chain ref instead (table above). Retooling CI to check out gnolang/gno@chain/topaz and vendor deps/avl remains a follow-up / owner decision per the PR discussion. Merge remains owner-gated.

Port all of gnodaokit to gno master (2c7f1abe324e, 2026-06-01) and the
interrealm v2 specification.

Interrealm v2:
- Crossing functions take `cur realm` as first param; cross-calls use
  `cross(cur)`. The realm is threaded only down the Execute path
  (DAO.Execute(id, rlm) -> Handler.Execute(action, rlm) -> executor),
  since Propose/Vote do not cross. Non-first realm params are named `rlm`.
- Drop the crossing-DAO wrapper: remove crossing.gno, daokit.NewCrossing,
  the CrossFn config field, and per-realm crossFn helpers. Demos use
  localDAO and a one-arg setImplem.
- Use chain/runtime/unsafe for PreviousRealm/CurrentRealm; keep
  chain/runtime for the Realm type and ChainHeight.

Tests:
- Test functions that cross-call take `func TestX(cur realm, t *testing.T)`.
- urequire PanicsWithMessage/NotPanics gain the new `rlm realm` arg.

Fixes beyond mechanical porting:
- Thread the realm through basedao.MigrateFn so the documented
  migration-via-basedao.New pattern compiles under v2.

Tooling and docs:
- Bump Makefile GNOVERSION to 2c7f1abe324e8fa6fac6dc71a36635cc4e92a0be.
- Update both READMEs to the v2 API (interfaces, Config, Quick Start,
  custom-resource and migration examples).
@zxxma

zxxma commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator Author

Gate review complete (independent reviewer, read-only): rename commit is merge-clean — all 558 diff lines verified as path/module/doc lines + the declared 2-line svg-boundary alias (forced: Topaz-genesis p/demo/svg types Canvas.Style as the new avl's *Tree, verified on-chain); zero ABI changes vs pr-64; 7/7 packages independently re-tested green at 67a0bb333.

Two decisions needed before merge (deliberately not taken autonomously):

  1. CI: workflows are pre-existing-red (pin 2c7f1abe + live-chain download resolution, structurally unfixable by a pin bump alone since p/samcrew/avl + /v2 paths exist on no live chain yet). The working fix is a ~40-line vendored-GNOROOT retool (pattern already green in samcrew-deployer CI; exact YAML in the review) — but that reinstates machinery @dvdo-gh previously reverted by choice. Options: fold the retool here, or merge on an explicit waiver with the retool as the immediate follow-up.
  2. feat: port to latest gno and interrealm v2 (cross(cur)) #64 supersession is partial: this branch carries feat: port to latest gno and interrealm v2 (cross(cur)) #64's first commit only; the later docs: align README examples with unexported localDAO delta (real security-relevant guidance) would be lost when feat: port to latest gno and interrealm v2 (cross(cur)) #64 closes — suggest cherry-picking it as a follow-up.

Minor follow-up either way: gno/r/daodemo/README.md still links the unsuffixed package paths (resolve to genesis, not the fork, on Topaz gnoweb).

@zxxma

zxxma commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator Author

Update — likely supersedes the CI question below: per gnolang/gno#5945 (Aeddi; final genesis kicks off tonight), the real Topaz genesis is a curated 90-package set that does NOT include p/samcrew/{daokit,basedao,daocond} (only piechart/tablesort/urlfilter) — the path collision this PR's /v2 rename solves will not exist on the launched chain (chain_id: topaz-1, base 959cefd91).

Recommendation: HOLD this PR until the launched genesis is inspected (Monday announce), then most likely: strip the /v2 renames (keep original module paths), retain the avl repoint (8 lines) + the svg-boundary ntavl alias (still required — p/demo/svg IS in the new genesis with the single-value avl Canvas.Style), and rebase the CI question onto the new base ref. If the final genesis differs from #5945's manifest, re-evaluate.

… paths)

topaz-1 launched with a curated genesis that does NOT contain
p/samcrew/{daokit,basedao,daocond} (verified live via vm/qpaths; only
piechart/tablesort/urlfilter) - the path collision that motivated the
/v2 rename never materialized, so the fork republishes at its original
paths and the rename is dropped.

- avl repoints x8: p/nt/avl/v0 -> p/samcrew/avl (x7) and /v0/pager ->
  p/samcrew/avl/pager (x1) - the vendored avl with two-value Get frozen;
  zero call-site changes.
- svg boundary (basedao/utils.gno): topaz-1 genesis p/demo/svg types
  Canvas.Style as *p/nt/avl/v0.Tree (verified on-chain via vm/qfile),
  so the canvas style tree keeps that type via an aliased ntavl import.
@zxxma
zxxma force-pushed the feat/topaz-v2-rename branch from 0612859 to 60c4bf0 Compare July 18, 2026 11:59
@zxxma zxxma changed the title feat: republish fork packages at /v2 paths for Topaz (supersedes #64) feat: republish fork at original paths for topaz-1: avl repoint + svg boundary (Q13 final form) Jul 18, 2026
@zxxma

zxxma commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator Author

Strip executed per the HOLD condition above — launched topaz-1 genesis verified live (vm/qpaths gno.land/p/samcrew = exactly {piechart, tablesort, urlfilter} — no daokit/basedao/daocond) → the /v2 rename is obsolete and has been dropped; the fork republishes at its ORIGINAL paths.

Branch reworked to a single commit atop #64's 15dbc83: 7 files, +10/−9 — only the avl repoints (×8) and the svg-boundary ntavl alias remain. The alias was re-verified as still required at chain/topaz (= fc4052651): live vm/qfile shows genesis p/demo/svg types Canvas.Style as *p/nt/avl/v0.Tree, and a negative compile without the alias fails with exactly the two boundary type errors. All 4 packages + 3 daodemo realms test/lint green at that tag (table in the updated description).

CI status unchanged (pre-existing red from the old 2c7f1abe pin — retool remains the follow-up/owner decision); merge stays owner-gated.

@davd-gzl davd-gzl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI bot]

The avl work checks out. Verified on 60c4bf0 against the launched chain: vm/qpaths gno.land/p/samcrew returns exactly piechart, tablesort and urlfilter, and vm/qfile shows live p/demo/svg declaring Style *avl.Tree over p/nt/avl/v0, whose Get is single-value.

The blocker is 15dbc83 underneath, unchanged here and unreviewed on this PR and on #64. Two defects ship with it, both inline: a DAO cannot identify a caller from another realm, and an action executed by that realm records its profile write under the caller instead of the DAO. Fixture and output: tests/.

The suite passes with both live, because every test drives the DAO from inside its own realm.

README.md:245 still tells integrators to export DAO, while this commit unexported it to localDAO in all three demos. Exporting it is what makes the Execute defect below reachable, and #64's dropped commit is what fixes the line.

Full review: https://github.com/samouraiworld/gno-agent-workspace/blob/main/reviews/gnodaokit/65-topaz-v2-rename/2-60c4bf0/review_claude-fable-5.md

Comment thread gno/p/daokit/daokit.gno
Execute(id uint64)
// The rlm realm is threaded so action handlers can perform
// cross-realm calls (e.g. editing the DAO profile).
Execute(id uint64, rlm realm)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Execute takes its realm from the caller, so a DAO action crosses under whichever realm invoked it and the profile write lands on that caller. The same realm flows through InstantExecute into a caller-supplied target DAO, so a parent executing on a sub-DAO overwrites its own profile. It travels to implementers too: Execute sits on the daokit.DAO and ActionHandler interfaces, so anything governance swaps in through ChangeDAOImplementation receives the caller's realm rather than inert identity.

repro

Two realms, one owning the DAO and one calling in, with a recording profile setter. NewEditProfileHandler writes with setter(cross(rlm), k, v), so the recorded realm is whichever one was passed to Execute. Fixture: https://github.com/samouraiworld/gno-agent-workspace/tree/main/reviews/gnodaokit/65-topaz-v2-rename/tests

setter observed: gno.land/r/test/daorlm|DisplayName=victim-dao
setter observed: gno.land/r/test/daorlm|Bio=d
setter observed: gno.land/r/test/daorlm|Avatar=
setter observed: gno.land/r/test/caller|Bio=written-by-caller

The first three are the DAO's own basedao.New init. The fourth is an EditProfile action executed by r/test/caller.

Comment thread gno/p/basedao/basedao.gno

func (d *daoPublic) Execute(id uint64) {
d.impl.Execute(id)
func (d *daoPublic) Execute(id uint64, rlm realm) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

CallerIDFn is a bare func() string reading unsafe.PreviousRealm(), which does not name the immediate caller across these non-crossing methods: a cross-realm caller resolves to the empty string. AddMember accepts that empty address as a member without validating it, so one such member authenticates every cross-realm caller. Execute here took a realm; Propose and Vote did not.

repro
CallerID for cross-realm caller = []

With one empty-address member registered, r/test/caller proposed, voted and executed on a DAO owned by r/test/daorlm. Without it the same run panics caller is not a member. Fixture: https://github.com/samouraiworld/gno-agent-workspace/tree/main/reviews/gnodaokit/65-topaz-v2-rename/tests

Comment thread gno/p/basedao/README.md Outdated

func Post(title, content string) {
caller := std.PrevRealm().Addr()
caller := unsafe.PreviousRealm().Address()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The member-only example authenticates with unsafe.PreviousRealm() inside a non-crossing Post, which names the outermost crossing realm rather than the immediate caller. It is the framework's only worked answer to gating on membership, so the pattern propagates.

Comment thread gno/p/daokit/actions.gno

func NewExecuteLambdaHandler() ActionHandler {
return NewActionHandler(ActionExecuteLambdaKind, func(i interface{}) {
return NewActionHandler(ActionExecuteLambdaKind, func(i interface{}, _ realm) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit: NewExecuteLambdaHandler drops its realm into _ and invokes a func() payload, so a lambda action cannot make the cross-realm call the threading was added for. NewInstantExecuteHandler below it forwards the realm, and nothing marks lambdas as the non-crossing kind.

Comment thread gno/p/basedao/basedao.gno
Members: members,
GetProfileString: conf.GetProfileString,
Realm: runtime.CurrentRealm(),
Realm: unsafe.CurrentRealm(),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit: New stores Realm: unsafe.CurrentRealm() although it already holds rlm. Both agree in the demos, where New only runs from init(cur realm), but DAOPrivate.Realm feeds the private-extension gate.

@davd-gzl davd-gzl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Automatic review 🆙, I will do a commit if necessary

…ive testnet

CI has been red since 2026-06-04, and the cause is not in this repo's code.
`gno lint` and `gno test` derive dependency sources from the pkgpath domain
(rpcpkgfetcher.go: https://rpc.%s:443), and rpc.gno.land CNAMEs to betanet — a
mutable testnet. A hermetically pinned compiler was being fed by a live,
unversioned source, so any upstream redeploy retroactively broke every branch,
including already-merged history.

Two independent failure classes, neither fixed by bumping the pin:

  1. Syntax skew — the chain serves pre-interrealm-v2 sources, i.e. the deps are
     OLDER than the pinned compiler, so bumping moves further away, not closer.
  2. Packages gone — r/demo/profile returns a server-side "not available". The
     failed fetch leaves the cache dir uncreated, which then resurfaces as a
     misleading `open …/p/onbloc/json: no such file or directory` — a masked
     download failure, not cache corruption.

Vendoring removes the network from the build, which is the only thing that closes
both. Zero code changes and zero Makefile changes: load.go short-circuits the
fetch on any workspace-local match. Placement at the repository root rather than
under gno/ is load-bearing — make lint/test/fmt all target ./gno/..., so vendored
code is resolved but never linted, tested or reformatted.

Result: lint clean, 6/6 packages ok, `gno fmt` zero diff, and no `gno: downloading`
line at all, with the network unavailable.

The avl role is vendored from the p/samcrew/avl FORK, not upstream. topaz-1's
stdlib p/nt/avl/v0 exposes a single-value Get while this codebase calls the
two-value form, so vendoring upstream there would produce a green build compiled
against an ABI the target chain does not have — a false green in exactly the place
a gate should prevent one. The one remaining stdlib avl import, in
basedao/utils.gno, is deliberate: svg.Canvas.Style is a *nt/avl/v0.Tree, so that
boundary must match the stdlib ABI, and it only calls NewTree().

Two guards keep this honest. The lint job now fails if `gno: downloading` ever
appears, so the closure cannot silently become incomplete. A new vendored-provenance
job proves every vendored file is byte-identical to gnolang/gno@GNOVERSION — 118
files, currently zero drift — refuses to pass vacuously if it checks nothing, and
asserts the fork still exposes the two-value Get. GNOVERSION is read from the
checked-out tree, so it is validated as a bare hex sha and passed through env
rather than interpolated into a run block, where a fork PR could otherwise inject.
zxxma and others added 17 commits July 20, 2026 14:12
…tion

Review follow-ups on the vendoring change.

The guard could be bypassed three ways. `find -type f` skips symlinks, but the
gno loader follows them, so a symlinked .gno was compiled while the byte
comparison never saw it — verified: it produced redeclaration errors across five
packages while the job still reported drift 0. Symlinks under vendored/ are now
refused outright. Deletions were invisible because the walk only visited files
that exist here; removing a single file from a vendored package left both the
provenance job AND lint green. The comparison now runs in both directions, scoped
to directories actually vendored as packages so intermediate namespace dirs do
not demand upstream files we never took.

More important, a green build here does NOT by itself prove the tree is
publishable, and the README said otherwise. GNOVERSION is 2c7f1abe; topaz-1 runs
fc4052651, so ~15 vendored packages differ from what the chain hosts — including
p/nt/avl/v0, whose on-chain Get is single-value while the vendored copy is
two-value. That is safe today for one narrow reason: gnodaokit crosses that
boundary only via ntavl.NewTree(), identical in both. Nothing enforced it, so a
single new ntavl.Get() would compile green here and fail AddPackage on-chain. CI
now asserts the boundary stays limited to NewTree, and the README states the real
reason rather than implying the vendored copy matches the chain.

Attribution: this redistributes 118 files covered by the GNO Network General
Public License, and the repo carried no notice. Adds upstream's LICENSE.md and a
NOTICE recording repo, commit and licence, both excluded from the comparison.

Also: one `${{ }}` was still interpolated inside a run: block, contradicting the
file's own comment — now passed via env. GNOVERSION is read with tail -1 to match
make's last-assignment-wins. The lint job pins a cold GNOHOME, because a warm
module cache short-circuits the fetch before the "downloading" line prints and
would silently disable the hermeticity check; it also captures the exit status so
the missing-package advice still prints when lint actually fails. checkout@v3 to
@v4 for consistency.
ci: vendor the dependency closure so the build stops depending on a live testnet
…k, and NaN escaping the threshold conditions (#67)

* fix(daocond): RoleThreshold proposal renders panic instead of displaying

RenderWithVotes consumed three format verbs (%g, %s, %s) while passing two
arguments. gno's ufmt panics on an argument shortfall rather than emitting
Go's cosmetic "%!s(MISSING)", so every proposal-detail render for a DAO whose
condition contains a RoleThreshold panicked — permanently, since publishing is
immutable.

The existing suite never caught it: daocond_test.gno only calls RenderWithVotes
inside its failure branch, so a passing run never executes the line. The new
test exercises it directly.

* fix(basedao): removing the last member bricks the DAO permanently

RemoveMember checked only IsMember, so a single-member DAO could remove
itself: 1/1 = 100% clears any threshold, and nothing stopped the removal.
The resulting zero-member DAO is unrecoverable — assertCallerIsMember
rejects every entry point, so not even AddMember can be proposed, and every
threshold evaluates 0/0 = NaN, which is never >= the threshold. Publishing
is immutable, so the brick would be permanent.

Test lives in members_removal_test.gno rather than members_test.gno to avoid
colliding with the file added in the realm-identity-hardening branch.

* fix(daocond): empty electorate yields NaN instead of an unmet condition

Both threshold conditions divide yes-votes by the size of their electorate.
gno's float64 divide has no zero guard — unlike every integer case, which
raises "division by zero" — so an empty electorate produces 0/0 = NaN. NaN
then escapes through Eval, Signal and RenderWithVotes; Signal is a progress
value and math.Min(NaN/threshold, 1) is NaN, not 1.

The minimum-member guard added alongside this does not cover it: a role can
reachably reach zero holders while the DAO still has members, via
RemoveRoleFromMember (a default-registered governance action), RemoveRole, or
removing the last holder of a role while others remain.

Zero resolves to 0.0, never 1.0 — reading an empty electorate as vacuous truth
would let a proposal pass with nobody entitled to vote on it. This mirrors the
guard gnolovDaoCondThreshold.voteRatio already carries for its zero-power case.

* fix(daocond): a roleless voter permanently bricks a gnolove DAO proposal

getUserRole panicked when a voter held none of the condition's tier roles.
Core.Vote gates on membership only, never on holding a tier role, so such a
voter can reach the ballot — as can any member when the condition is built over
a subset of the DAO's roles, which is exactly what the "T3 abstaining" case
models. The panic was raised from inside the ballot walk, so one such vote made
every later Eval, Signal and Render on that proposal panic. On an immutable
publish that is unrecoverable, and it is reached by an ordinary member casting an
ordinary vote.

A voter outside the condition's roles now carries no voting power: "" is absent
from votingPowersByTier, so the lookup yields 0.0 and they contribute nothing.

This changes a deliberately asserted behaviour, so it is worth being explicit
about why it is a fix rather than a regression. The existing matrix case carried
`panic: true` alongside `expectedYes: 7.0/10.0` — and 7/10 is precisely the tally
with the T3 votes excluded, i.e. the number the case would produce under this
change. The panic flag documented what the code did; the expectation recorded
what it was meant to do. With the flag removed the case now genuinely evaluates
Eval(ballot) == true instead of passing through the recover path, so the
assertion is exercised for the first time.

---------

Co-authored-by: zxxma <zxxma@users.noreply.github.com>
Closes both identity blockers as one interface change, since they are the same
defect seen from two sides.

Propose(req, rlm) / Vote(id, vote, rlm) / Execute(id, rlm) each assert the
threaded realm is the DAO realm's own live one before doing anything else.
Execute forwards that realm to the action handlers, which cross out under it, so
whoever supplies it decides the identity the DAO acts as: a third realm holding
the DAO value could pass its own and have the DAO write to that realm's profile,
or via MigrateFn reach anywhere it controls. Realm values are unforgeable and
cannot be persisted across transactions, so a caller can only pass its own;
requiring it to equal the DAO's own closes that path outright.

Reached through the DAO handle there is no DAO realm frame on the stack at all,
so the old stack-walking identity named the signing account. A member's
signature then satisfied the membership check while the caller supplied the
realm the DAO acted under. Identity now derives from the threaded realm, which
does not depend on where in the chain it is read.

The gate requires the realm to be current, not merely to match by pkgpath. Every
realm the DAO crosses out into during an action receives the DAO's own realm as
its cur.Previous() and can hand that value straight back within the same
transaction: same pkgpath, dead frame. Reproduced end to end — before this, a
callee re-entered Propose under the DAO's own identity and a pkgpath-only gate
accepted it. IsCurrent() is frame identity rather than name; it survives the /p/
hop into basedao and holds during a realm's own init, so neither the ordinary
path nor construction is affected.

The realm is never a first parameter: the VM reads any function whose first
parameter is a realm as crossing, and /p/ packages may not declare crossing
functions. Receivers do not count, so assertRealmIsOwn and defaultCallerID take
the DAO first.

Tests are realm-to-realm, under gno/r/daoidentity. testing.SetRealm fabricates a
cur with no frame beneath it — cur.Previous() resolves to p/samcrew/basedao
itself — so it cannot express a caller chain in either direction, which is why
the original defect and the New() regression in #66 both passed CI. The suite
drives a real DAO realm from a relay, a non-member, an attacker holding the DAO
value, and a callee re-entering with the DAO's own dead-frame realm.

Five properties are mutation-checked, each failing exactly one test: either half
of the realm gate, the empty-id guard, the gate running before CallerID ever
sees a realm, and Execute requiring membership. The ordering matters because
CallerIDFn is a frozen extension point — running membership first would hand a
custom implementation an attacker-controlled realm.

basedao's unit tests now declare the caller they act as instead of leaning on
the harness, and realm_identity_test.gno is dropped: SetRealm-based identity
tests claim coverage that cannot exist.

The empty-id guard is load-bearing rather than cosmetic. AddMember does not
reject "", Members is an exported avl.Tree a MigrateFn can seed directly, and
any call the machine cannot attribute to a signer resolves to "" — so one such
entry would otherwise authenticate all of them. It is asserted on controlled
input, not inferred from the environment: under gno test the harness leaves
OriginCaller unset, while on-chain a root-of-chain call resolves to the signing
account.
"" 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.
GNOVERSION was 2c7f1abe, six weeks older than the chain this is about to be
published to immutably. Now fc4052651, which is what topaz-1 runs.

The skew was not theoretical. Roughly 15 vendored packages differed from what
the chain hosts, including p/nt/avl/v0: its Get is single-value on-chain and was
two-value in the vendored copy. A green build did not prove publishability, and
the gap was held open by a hand argument about which symbols gnodaokit happened
to touch. Regenerating at the chain's ref closes it — the vendored stdlib avl is
now single-value, matching what AddPackage will resolve.

The old toolchain also had no sub-realm support at all: cur.Sub() failed
preprocessing, and realmSubpathOf / topmostCrossingFrameCurHIV are absent from
the binary. Nothing could exercise the sub-realm semantics the identity work
reasons about, on the compiler the freeze was being validated with.

15 files changed content, one was added, and p/moul/md/filetests is gone
upstream — its filetest became example_test.gno in the package. The fork at
p/samcrew/avl is untouched and still exposes the two-value Get.

Verified at the new pin with the network unavailable: 8 packages ok, lint clean,
gno fmt zero diff, zero "gno: downloading" lines, and the provenance comparison
run locally in both directions — 118 files checked, 0 drift, 0 deleted,
0 symlinks.

The stdlib-avl boundary gate stays, but it is belt-and-braces now rather than
load-bearing: a misuse fails the local build instead of surviving to AddPackage.
Its comment and vendored/README.md said the opposite and are corrected.
…-entrancy it was hiding

Any realm holding the DAO handle could permanently brick a proposal that had
already met its condition, with one cheap call.

Render is on the cross-realm DAO interface and reaches GetProposals, which
called UpdateStatus on every proposal it walked — the code's own comment said
"costly and probably insecure". Vote never moves the status, so a proposal sat
at Open after reaching its threshold; the render flipped it to Passed, and
Execute then refused it forever because it demanded exactly Open. Repeatable
after every re-vote. GetProposalsJSON and the proposal detail view wrote on read
the same way.

Reading no longer writes. DisplayStatus computes the status a proposal should be
shown as, and every read path uses it. UpdateStatus stays — persisting the passed
state is a legitimate thing for a realm to want — but nothing in this package
calls it now.

Execute is gated on the condition and on nothing else. Executed is the only
status that disqualifies a proposal; requiring Open made the status a second,
weaker gate that anything able to move it could use to deny execution.

The executed marker moves BEFORE the handler runs. That ordering was previously
irrelevant, because "must be Open" happened to block re-entry once UpdateStatus
had moved the proposal to Passed. Removing that requirement — which is what
unbricks rendering — would have opened re-entrancy had the marker stayed put.
Verified: with the marker after the handler, a proposal whose action calls back
into Execute recurses without bound, and the suite hangs rather than failing.

Three properties, each mutation-checked against its own test: restoring the
mutating read path fails the brick test, requiring Open fails the
persisted-Passed test, and moving the marker back re-opens the recursion.
…not a stack walk

Extension asked unsafe.CurrentRealm(), which answers "is a DAO frame the
innermost live one" rather than "is my caller the DAO". That is wrong in both
directions.

Too lax: anything the DAO invoked WITHOUT crossing inherited the DAO's realm and
passed the check — including a proposer-authored ExecuteLambda callback, which
could read a private extension.

Too strict: a DAO-realm helper that is not itself a crossing function has no
frame for the walk to find, so the DAO was locked out of its own private
extensions through any read-only accessor.

It now takes the threaded realm and, for a private extension only, requires the
DAO realm's own live one — the same test the entry points use. That closes the
lambda case by construction rather than by check: a callback given no realm
cannot produce one, and realm values can be neither forged nor persisted.

Public extensions ignore the realm entirely, so MembersViewExtension — the
documented way for another realm to check membership — keeps working from any
caller. Gating those too would have broken it, and the suite catches that
mutation as well as the reverse.

This changes daokit.DAO, so it is now or never.
A passing migration hands proposer-authored code the DAO's live realm and its
full private state. Readonly taint blocks a direct field write but not method
dispatch, so the migration can commit under the DAO's authority — it is a
takeover in the general case, not an upgrade.

It was registered with the same condition as "Add Member", so both cost the
same 60% by default. Migration now defaults to 80%, and Config.MigrationCondition
makes that explicit for a DAO wanting something else. Nothing is deployed at this
path yet, so the stricter default costs nothing and the safe direction is the one
that is hard to reverse.

And every migration rendered as the same fixed sentence, which told a voter
nothing: a routine version bump and a takeover were indistinguishable in the
proposal they were approving. A function value cannot be rendered, so the caller
now has to supply a label, and the warning says what approving actually grants.
…e the demos bypass the gate

InstantExecute threads the caller's realm through Propose, Vote and Execute, and
each entry point requires its own — so handing it a DAO belonging to another
realm is now refused, and NewInstantExecuteAction inherits that.

That refusal is the correct outcome, not a regression to work around. Driving a
foreign DAO by passing it your realm IS the donation shape: it makes that DAO act
under your identity. It appeared to work only because nothing checked. A parent
DAO still drives a child by reaching it through the child REALM's own crossing
function, so the child mints its own realm and authorises the parent as an
ordinary member. Both are documented and the constraint is pinned by a test.

The three demo realms call daoPrivate.CallerID(daoPrivate, cur) directly, which
skips the entry-point gate. It is correct there — cur is the realm's own, minted
by the crossing function they are in — but it is also the shape a reader is most
likely to copy, and copied somewhere that forwards a realm received from
elsewhere it becomes the bug the gate exists to refuse. Said so at each site.
The stricter migration default I just added was wrong in the case that matters
most, and made the thing it was meant to protect easier.

A Condition is opaque, so there is no way to "raise" one. Substituting a members
threshold for a role-gated condition does not tighten it — it DROPS the role
gate. Measured against And(MembersThreshold(0.4), RoleCount(1,"officer")), which
is the shape every demo realm uses: a ballot that FAILED the ordinary action
PASSED the bare 0.8 migration. A takeover became cheaper than adding a member.

The default is now InitialCondition AND an 80% member majority, so it is harder
along every dimension the DAO's own governance measures and along one more.
Pinned by a test that votes four of five members with the officer abstaining —
refused by both, where before it was refused by one and admitted by the other.
It read "only accessible from the same realm that registered it", which invites
being taken for confidentiality. It is not. Realm state on a public chain is
world-readable over ABCI, and ExtensionsList hands out every ExtensionInfo —
including QueryPath — with no check at all.

What Private restricts is who can obtain the extension VALUE through
DAO.Extension and therefore call its methods under the DAO's authority. That is
a capability. Leaving the listing ungated is correct for the same reason: gating
metadata would imply a secrecy the chain cannot provide, while the capability
door stays shut.
…nd in the fix itself

Three real defects in the previous four commits.

Core.Vote still demanded status Open while Execute had been relaxed, and
UpdateStatus was exported and blessed. Together those inverted the bug rather
than fixing it: persisting Passed used to brick a proposal, and instead began
LOCKING IT IN — votes frozen, support unable to be withdrawn, execution
guaranteed. Status is now written only by Execute, UpdateStatus is gone, and
Vote and Execute share one terminal state. A ballot stays live until the
proposal executes, which is the coherent reading and is now pinned by a test
that withdraws support after the condition is met and takes it back.

The migration default could make migration permanently unreachable. Conjoining
an 80% member threshold onto role-based governance demands a member majority a
role-governed DAO may never assemble, and migration is the one rule that cannot
be repaired afterwards, because repairing it needs a migration. A DAO that chose
its own governance now keeps it, with the docs saying plainly to set
MigrationCondition; only a DAO on the default 60% gets the raise to 80%, where
it is the same dimension and a genuine strengthening.

New also wrote that default back into the caller's Config, and the condition
closes over the member store — so one Config reused for a second DAO gave it a
migration rule evaluating the first DAO's membership. Held locally now.

The IsCurrent() half of the private-extension gate had no test at all: replacing
it with a pkgpath comparison survived the whole suite, and under that mutation a
callee handed the DAO's dead-frame realm reads the private extension. Covered
now, and the mutation dies.

Also: Execute is not retry-safe, because gno's recover() does not roll back realm
state — a host that recovers around a failing Execute keeps the marker and burns
the proposal. Documented, since the ordering is worth more than the retry.

The read paths that this change set exists to fix had no tests; one now renders
an open, a condition-met and an executed proposal and checks the table, the JSON
and the active/history split, killing three mutations that had survived. The
other two turned out to be equivalent — with Passed never stored, filtering on
the raw status is exactly "not yet executed" — so the filters use it directly and
stop evaluating every condition a second time.

Finally, the migration label is caller-written text, not a safety control; a
takeover can ship as "routine security patch". Said so, so the docs do not imply
otherwise.
zxxma and others added 6 commits July 20, 2026 20:26
…okit#13)

Action.String() is what a member reads before voting, and for an action built
with NewAction it is the payload's own rendering — supplied by whoever created
the proposal. Issue #13 asks what stops that lying.

Two things do, and neither was written down. Type() must be truthful or the
wrong handler is looked up and its assertion fails, so an action cannot disguise
its KIND; and the proposal view already renders the Resource's registered
DisplayName, Description and Condition beside it, keyed by Type() from the DAO's
own registry rather than from the proposal. What remains reachable is
misrepresenting the payload's DETAIL, and only through a handler that admits a
hostile payload.

The defence is the concrete type assertion, so that contract is now stated at
NewActionHandler and demonstrated both ways: a spoofed payload rendering
identically to an honest one is rejected by a concrete assertion, and admitted
by an interface assertion — a payload of 1000000 that reads as 1. Nothing in
daokit can enforce this, since the handler decides, which is exactly why it is
pinned as a fact about the pattern.

Every shipped handler already asserts concretely, and the two destructive ones —
basedao's ChangeDAOImplementation and daokit's InstantExecute — use unexported
payload types a proposer cannot construct at all. So #13 is not reachable in
shipped code; it is a footgun for third-party action authors.

Moving rendering onto the handler, as #13 suggests, would remove the footgun
instead of documenting it. That changes ActionHandler, and swapping a frozen
interface on the last day before an immutable publish to close a hole nothing
shipped can reach is the wrong trade — recorded for a version boundary.
…es it safe

Owner call: keep it on the exported surface. It is an API removal on a package
with a live test13 deployment, and the reason it was dangerous is gone.

It was removed because it inverted the lifecycle fix — but only in combination
with checks that no longer exist. When Vote and Execute demanded status Open,
persisting Passed was destructive twice over: the ballot froze, so support could
not be withdrawn, and the proposal became permanently unexecutable. Both now key
on Executed alone, so persisting the passed state changes nothing about what a
proposal can still do.

That is an invariant, not a coincidence, so it is pinned: a test persists Passed,
then withdraws support and shows Execute refuses on the condition, then restores
it and shows Execute succeeds. Re-arming either check fails it — verified for
both — and it says in the test what to do if it ever goes red: take UpdateStatus
out rather than work around it.

The doc comment now states all three hazards plainly: safe only because of those
two checks, never call it from a read path, and once persisted the status stops
tracking the votes.
fix(basedao,daokit): bind the DAO's identity to its own live realm
fix(basedao,daokit,daocond): settle the exported surface before it freezes
chore: pin the toolchain to topaz-1's own ref and regenerate vendored/
…extension-gate

fix(daokit,basedao): proposal lifecycle, the extension gate, and the migration threshold
@davd-gzl
davd-gzl self-requested a review July 27, 2026 08:53

@davd-gzl davd-gzl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI bot]

Automated pass over the diff. Technical checks only: no design judgement and no merge verdict.

Verified on 0eb8518: dropping the IsCurrent() clause reddens exactly the two dead-frame tests and dropping the pkgpath comparison reddens six, so both halves of the gate carry weight. A migration authored in a different realm still produces a DAO bound to the host realm, checked across three real realms.

Two process notes:

  • The description says 7 files, +10/−9. The head is 225 files, +26323/−447, and it re-signatures daokit.DAO, daokit.ActionHandler, basedao.Config, CallerIDFn, MigrateFn and SetImplemRaw. The CI retool it lists as a follow-up has landed.
  • #67 through #72 were merged into this branch rather than into main and carry no reviews, so merging this is the only gate any of them passes. Deliberate?

Five more sit on lines this diff does not touch, so they have no inline anchor:

  • view_proposal_detail_page.gno:32-34 reads proposal.Title straight off a nil GetProposal, so proposal/0 and any unused id abort on the cross-realm handle gnoweb drives. proposal/<non-numeric> aborts in MuxProposalDetailPage and role/<absent name> in RoleInfo. All four predate this branch, and 7a18b35 here sweeps that class.
  • gno/p/basedao/README.md:186-192 offers proposals/1 and roles, which both 404; the router registers proposal/{id} and role/{name} at render.gno:31-39. Three registered paths are missing from the list.
  • gno/p/basedao/README.md:281-310 and README.md:206-235 both omit MigrationCondition, whose own comment tells a caller who sets InitialCondition to set it too.
  • cond_role_treshold.gno misspells treshold in its filename and in the new cond_role_treshold_test.gno; the identifiers inside are correct. File names are what vm/qfile and gnoweb list, so this freezes with the rest.
  • Makefile:22 globs gno.mod, of which the repo has zero; all 16 manifests are gnomod.toml, so the gno mod tidy step and the no-diff check after it assert nothing.
repro
# from a local clone of samouraiworld/gnodaokit:
gh pr checkout 65 -R samouraiworld/gnodaokit
go build -o /tmp/gno-topaz github.com/gnolang/gno/gnovm/cmd/gno@fc40526511474e40b8a66419f5ba28255085bc08

cat > gno/p/basedao/render_probe_test.gno <<'EOF'
package basedao

import "testing"

func TestRenderProbe(cur realm, t *testing.T) {
	tdao := newTestingDAO(cur, t, 0.6, []Member{
		{alice.String(), []string{"admin"}}, {bob.String(), []string{}},
	})
	tdao.dao.Propose(tdao.mockProposalRequest, cur)

	for _, p := range []string{"proposal/1", "proposal/0", "proposal/999", "proposal/abc", "role/admin", "role/nope"} {
		func() {
			defer func() {
				if r := recover(); r != nil {
					println("PANIC  " + p)
				}
			}()
			tdao.privdao.Render(p)
			println("ok     " + p)
		}()
	}
}
EOF

/tmp/gno-topaz test -v -run 'TestRenderProbe' ./gno/p/basedao
rm gno/p/basedao/render_probe_test.gno
ok     proposal/1
PANIC  proposal/0
PANIC  proposal/999
PANIC  proposal/abc
ok     role/admin
PANIC  role/nope

Full review: https://github.com/samouraiworld/gno-agent-workspace/blob/main/reviews/gnodaokit/65-topaz-v2-rename/3-0eb8518/review_claude-opus-5_davd-gzl.md

Comment thread gno/p/daokit/daokit.gno
Comment on lines 26 to 43
type DAO interface {
// Creates a new proposal and returns its ID.
Propose(req ProposalRequest) uint64
Propose(req ProposalRequest, rlm realm) uint64
// Casts a vote on a specific proposal.
Vote(id uint64, vote daocond.Vote)
Vote(id uint64, vote daocond.Vote, rlm realm)
// Executes a proposal if it meets the required conditions.
Execute(id uint64)
Execute(id uint64, rlm realm)

// Generates a web interface representation for the given path.
Render(path string) string

// Gets an extension by path, returns nil if not found.
Extension(path string) Extension
// Gets an extension by path, returns nil if not found. A PRIVATE extension
// additionally requires the DAO realm's own live realm, on the same terms
// as the entry points above; a public one ignores it.
Extension(path string, rlm realm) Extension
// Lists all available extensions.
ExtensionsList() ExtensionsList
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Critical: every DAO method takes the caller's realm, so a realm querying a DAO it does not own hands the implementation a capability to act as itself. assertRealmIsOwn guards the callee only, and the interface is satisfiable by anyone: MustGetMembersViewExtension forwards the caller's rlm straight into it. Taking the caller's address instead removes the transfer; a doc line cannot, because the interface is what third-party implementations conform to.

repro
# from a local clone of samouraiworld/gnodaokit:
gh pr checkout 65 -R samouraiworld/gnodaokit
go build -o /tmp/gno-topaz github.com/gnolang/gno/gnovm/cmd/gno@fc40526511474e40b8a66419f5ba28255085bc08

mkdir -p gno/r/authlens/{probe,victim,evil,asuite}
for d in probe victim evil asuite; do
  printf 'module = "gno.land/r/samcrew/authlens/%s"\ngno = "0.9"\n' "$d" > "gno/r/authlens/$d/gnomod.toml"
done

cat > gno/r/authlens/probe/probe.gno <<'EOF'
package probe

var last string

func Record(cur realm) {
	p := cur.Previous()
	if p.IsUser() {
		last = "user:" + p.Address().String()
	} else {
		last = p.PkgPath()
	}
}

func Last() string { return last }
func Reset()       { last = "" }
EOF

cat > gno/r/authlens/evil/evil.gno <<'EOF'
package evil

import (
	"gno.land/p/samcrew/daocond"
	"gno.land/p/samcrew/daokit"
	"gno.land/r/samcrew/authlens/probe"
)

type evilDAO struct{}

func (e *evilDAO) Propose(req daokit.ProposalRequest, rlm realm) uint64 { probe.Record(cross(rlm)); return 0 }
func (e *evilDAO) Vote(id uint64, vote daocond.Vote, rlm realm)         { probe.Record(cross(rlm)) }
func (e *evilDAO) Execute(id uint64, rlm realm)                         { probe.Record(cross(rlm)) }
func (e *evilDAO) Render(path string) string                            { return "" }
func (e *evilDAO) ExtensionsList() daokit.ExtensionsList                 { return nil }

func (e *evilDAO) Extension(path string, rlm realm) daokit.Extension {
	probe.Record(cross(rlm))
	return &fakeMembersView{}
}

type fakeMembersView struct{}

func (f *fakeMembersView) Info() daokit.ExtensionInfo {
	return daokit.ExtensionInfo{Path: "gno.land/p/samcrew/basedao.MembersView", Version: "1"}
}
func (f *fakeMembersView) IsMember(id string) bool { return true }

func Handle() daokit.DAO { return &evilDAO{} }
EOF

cat > gno/r/authlens/victim/victim.gno <<'EOF'
package victim

import (
	"gno.land/p/samcrew/basedao"
	"gno.land/p/samcrew/daokit"
)

// The documented cross-realm membership check.
func CheckMembership(cur realm, dao daokit.DAO, who string) bool {
	view := basedao.MustGetMembersViewExtension(dao, cur)
	return view.IsMember(who)
}
EOF

cat > gno/r/authlens/asuite/asuite_test.gno <<'EOF'
package asuite

import (
	"testing"

	"gno.land/p/nt/urequire/v0"
	"gno.land/r/samcrew/authlens/evil"
	"gno.land/r/samcrew/authlens/probe"
	"gno.land/r/samcrew/authlens/victim"
)

func TestMembersViewRecipeDonatesTheCallersRealm(cur realm, t *testing.T) {
	probe.Reset()
	victim.CheckMembership(cross(cur), evil.Handle(), "whoever")
	urequire.Equal(t, "", probe.Last(),
		"the DAO implementation must not be able to act as the victim realm")
}
EOF

/tmp/gno-topaz test -v ./gno/r/authlens/asuite
rm -rf gno/r/authlens
=== RUN   TestMembersViewRecipeDonatesTheCallersRealm
uassert.Equal: strings are different
	Diff: [+gno.land/r/samcrew/authlens/victim] - the DAO implementation must not be able to act as the victim realm
--- FAIL: TestMembersViewRecipeDonatesTheCallersRealm (0.00s)

A third realm saw the victim as its caller.

# single-value while this codebase calls the two-value form. Its own
# provenance is guarded in samouraiworld/samcrew-deployer against
# upstream f3d5a5d13. See vendored/README.md.
gno.land/p/samcrew/avl/*) skipped=$((skipped + 1)); continue ;;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Critical: the exemption is a directory prefix, but the compiler resolves a package by the module line in its gnomod.toml. A directory under the exempt prefix can therefore claim any package path and become what the build compiles, while the job reports no drift and lint stays clean.

repro
# from a local clone of samouraiworld/gnodaokit:
gh pr checkout 65 -R samouraiworld/gnodaokit
go build -o /tmp/gno-topaz github.com/gnolang/gno/gnovm/cmd/gno@fc40526511474e40b8a66419f5ba28255085bc08

git clone --filter=blob:none --no-checkout https://github.com/gnolang/gno /tmp/gnoup
git -C /tmp/gnoup checkout --quiet fc40526511474e40b8a66419f5ba28255085bc08 -- examples

# A shadow package under the exempt prefix, claiming piechart's path. Its Render
# drops the title parameter, so whichever copy compiles is observable.
mkdir -p vendored/gno.land/p/samcrew/avl/shadow
printf 'module = "gno.land/p/samcrew/piechart"\ngno = "0.9"\n' > vendored/gno.land/p/samcrew/avl/shadow/gnomod.toml
sed 's|^func Render(slices \[\]PieSlice, title string) string {|func Render(slices []PieSlice) string {\n\ttitle := "SHADOWED"|' \
  vendored/gno.land/p/samcrew/piechart/piechart.gno > vendored/gno.land/p/samcrew/avl/shadow/piechart.gno

# The workflow's own byte-comparison loop.
drift=0; checked=0
while IFS= read -r f; do
  rel="${f#vendored/}"
  case "$rel" in
    gno.land/p/samcrew/avl/*) continue ;;
    README.md|NOTICE|LICENSE.md) continue ;;
  esac
  checked=$((checked + 1))
  if [ ! -f "/tmp/gnoup/examples/$rel" ]; then echo "MISSING UPSTREAM: $rel"; drift=$((drift+1));
  elif ! cmp -s "$f" "/tmp/gnoup/examples/$rel"; then echo "DRIFT: $rel"; drift=$((drift+1)); fi
done < <(find vendored ! -type d)
echo "provenance: checked $checked, drift $drift"

/tmp/gno-topaz lint ./gno/...

rm -rf vendored/gno.land/p/samcrew/avl/shadow /tmp/gnoup
provenance: checked 118, drift 0
gno/p/basedao/view_members_page.gno:40:35: too many arguments in call to piechart.Render
	have ([]piechart.PieSlice, string)
	want ([]piechart.PieSlice) (code=gnoTypeCheckError)

Provenance passes, and the compile error is against the shadow's signature, so the shadow is what the build resolved. Keep the signature identical and the substitution is silent: with a byte-copy of piechart parked there, provenance reports the same drift 0, lint ./gno/... exits 0 and test ./gno/p/basedao is ok.

Comment thread gno/p/basedao/basedao.gno
if !conf.NoDefaultHandlers {
// Whether the DAO chose its own governance decides how far the migration
// default may go, below. Captured before the default is filled in.
governanceIsCallerChosen := conf.InitialCondition != nil

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

New writes its defaults back into the caller's Config, so a second DAO built from the same Config finds conf.InitialCondition already set at line 208 and its migration bar falls from 80% to the first DAO's 0.6 default, bound to the first DAO's member store. The comment at line 230 states the opposite invariant and names this exact hazard. conf.CallerID at line 170 and conf.MigrationParamsFn at line 227 are written back too.

repro
# from a local clone of samouraiworld/gnodaokit:
gh pr checkout 65 -R samouraiworld/gnodaokit
go build -o /tmp/gno-topaz github.com/gnolang/gno/gnovm/cmd/gno@fc40526511474e40b8a66419f5ba28255085bc08

cat > gno/p/basedao/config_reuse_probe_test.gno <<'EOF'
package basedao

import (
	"testing"

	"gno.land/p/nt/urequire/v0"
	"gno.land/p/samcrew/daokit"
)

func TestConfigReuseKeepsTheMigrationBar(cur realm, t *testing.T) {
	conf := &Config{
		Name:             "d",
		Description:      "d",
		GetProfileString: func(addr address, field, def string) string { return "" },
		SetImplemFn:      func(daokit.DAO) {},
	}

	testing.SetOriginCaller(alice)
	testing.SetRealm(testing.NewCodeRealm("gno.land/r/testing/dao1"))
	conf.Members = NewMembersStore(nil, []Member{
		{alice.String(), nil}, {bob.String(), nil}, {carol.String(), nil},
	})
	_, first := New(conf, cur)

	testing.SetRealm(testing.NewCodeRealm("gno.land/r/testing/dao2"))
	conf.Members = NewMembersStore(nil, []Member{
		{alice.String(), nil}, {bob.String(), nil}, {carol.String(), nil},
	})
	_, second := New(conf, cur)

	firstMig := first.Core.Resources.Get(ActionChangeDAOImplementationKind).Condition
	secondMig := second.Core.Resources.Get(ActionChangeDAOImplementationKind).Condition
	urequire.Equal(t, firstMig.Render(), secondMig.Render(),
		"two DAOs built from one default Config must get the same migration bar")
}
EOF

/tmp/gno-topaz test -v -run 'TestConfigReuseKeepsTheMigrationBar' ./gno/p/basedao
rm gno/p/basedao/config_reuse_probe_test.gno
=== RUN   TestConfigReuseKeepsTheMigrationBar
uassert.Equal: strings are different
	Diff: [-8][+6]0% of members - two DAOs built from one default Config must get the same migration bar
--- FAIL: TestConfigReuseKeepsTheMigrationBar (0.01s)

Comment on lines +164 to +177
- name: The fork must expose the two-value Get this codebase calls
run: |
set -euo pipefail
tree="vendored/gno.land/p/samcrew/avl/tree.gno"
if [[ ! -f "$tree" ]]; then
echo "ERROR: the vendored p/samcrew/avl fork is missing"
exit 1
fi
if ! grep -qE 'func \(tree \*Tree\) Get\(key string\) \(value any, exists bool\)' "$tree"; then
echo "ERROR: vendored p/samcrew/avl no longer exposes the two-value Get:"
grep -nE 'func \(tree \*Tree\) Get\(' "$tree" || true
exit 1
fi
echo "p/samcrew/avl exposes the two-value Get, as this codebase requires"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The fork is checked only by grepping its Get signature, so a change to the read path every member, role and proposal lookup goes through passes every gate. vendored/README.md:36 names samouraiworld/samcrew-deployer as the guard that pins the fork; that repository is private, so a reader of this one cannot verify the claim either.

Comment thread gno/p/daokit/daokit.gno
Comment on lines 137 to +140
proposal.Status = ProposalStatusExecuted
proposal.ExecutedAt = time.Now()

d.Resources.Get(proposal.Action.Type()).Handler.Execute(proposal.Action, rlm)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Marking the proposal before the handler runs makes a failed execution indistinguishable from a successful one. A host realm that recovers, the case the comment above warns about, leaves the proposal stored as Executed, rendering Status - Executed, out of the active list and in history, with its action never applied. At the merge-base the same failure left it visibly stuck as Passed in the active list.

repro
# from a local clone of samouraiworld/gnodaokit:
gh pr checkout 65 -R samouraiworld/gnodaokit
go build -o /tmp/gno-topaz github.com/gnolang/gno/gnovm/cmd/gno@fc40526511474e40b8a66419f5ba28255085bc08

mkdir -p gno/r/burnprobe/{host,suite}
printf 'module = "gno.land/r/burnprobe/host"\ngno = "0.9"\n' > gno/r/burnprobe/host/gnomod.toml
printf 'module = "gno.land/r/burnprobe/suite"\ngno = "0.9"\n' > gno/r/burnprobe/suite/gnomod.toml

cat > gno/r/burnprobe/host/host.gno <<'EOF'
package host

import (
	"gno.land/p/samcrew/basedao"
	"gno.land/p/samcrew/daocond"
	"gno.land/p/samcrew/daokit"
)

const SuiteID = "gno.land/r/burnprobe/suite"

var (
	localDAO   daokit.DAO
	daoPrivate *basedao.DAOPrivate
)

func init(cur realm) {
	members := basedao.NewMembersStore(nil, []basedao.Member{{Address: SuiteID}})
	cond := daocond.MembersThreshold(0.1, members.IsMember, members.MembersCount)
	localDAO, daoPrivate = basedao.New(&basedao.Config{
		Name: "Burn DAO", Description: "burn probe",
		Members: members, InitialCondition: cond,
		GetProfileString: func(addr address, field, def string) string { return "" },
		PrivateVarName:   "daoPrivate",
		NoCreationEvent:  true,
	}, cur)
}

func Propose(cur realm, req daokit.ProposalRequest) uint64 { return localDAO.Propose(req, cur) }
func Vote(cur realm, id uint64, v daocond.Vote)            { localDAO.Vote(id, v, cur) }

// The recover the daokit.gno comment warns about.
func ExecuteRecovering(cur realm, id uint64) (caught string) {
	defer func() {
		if r := recover(); r != nil {
			caught = "recovered"
		}
	}()
	localDAO.Execute(id, cur)
	return "no panic"
}

func StatusOf(id uint64) string { return daoPrivate.Core.Proposals.GetProposal(id).Status.String() }
func Detail() string            { return daoPrivate.Render("proposal/1") }
func JSON() string              { return daoPrivate.Core.Proposals.GetProposalsJSON() }

// Make the pending AddMember fail.
func SeedDuplicate(cur realm, who string) { daoPrivate.Members.AddMember(who, nil) }
EOF

cat > gno/r/burnprobe/suite/suite_test.gno <<'EOF'
package suite

import (
	"strings"
	"testing"

	"gno.land/p/samcrew/basedao"
	"gno.land/p/samcrew/daocond"
	"gno.land/p/samcrew/daokit"
	"gno.land/r/burnprobe/host"
)

const target = "g1v9kxjcm9ta047h6lta047h6lta047h6lzd40gh"

func TestBurn(cur realm, t *testing.T) {
	id := host.Propose(cross(cur), daokit.ProposalRequest{
		Title:  "add a member",
		Action: basedao.NewAddMemberAction(&basedao.ActionAddMember{Address: target}),
	})
	host.Vote(cross(cur), id, daocond.VoteYes)
	host.SeedDuplicate(cross(cur), target)

	println("recover() around Execute -> " + host.ExecuteRecovering(cross(cur), id))
	println("stored status            -> " + host.StatusOf(id))
	println("detail shows Executed    -> ", strings.Contains(host.Detail(), "Status - Executed"))
	println("json says Executed       -> ", strings.Contains(host.JSON(), "\"status\":\"Executed\""))
}
EOF

/tmp/gno-topaz test -v ./gno/r/burnprobe/suite
rm -rf gno/r/burnprobe
recover() around Execute -> recovered
stored status            -> Executed
detail shows Executed    ->  true
json says Executed       ->  true
--- PASS: TestBurn (0.02s)

Comment on lines +120 to +122
// which is the whole defect, relocated into the extension point. Nothing else
// in the suite pins the ordering: swapping the two lines leaves every other
// test green.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit: swapping the gate and CallerID in Propose alone also reddens TestInstantExecuteIsSameRealmOnly, which wants realm mismatch: ... and gets caller id is empty.

Comment on lines +29 to +30
// Raw status, not DisplayStatus: only Execute writes Status, so a
// stored proposal is Open until Executed and this is exactly

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit: this says only Execute writes Status. 1eabd78 re-exported UpdateStatus, which also does.

// persisted the status no longer tracks the votes: withdraw support afterwards
// and this still reads Passed, though Execute re-evaluates the condition and
// will refuse.
func (p *Proposal) UpdateStatus() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggestion: this freezes as a method its own doc says nothing in the package may call, that must not run while rendering, and that is safe only while Vote and Execute both key on Executed alone. Its only caller in the tree is the probe at dao.gno:199, added to show calling it is harmless. Publishing makes that constraint permanent and enforced only by a comment.

Comment thread gno/p/realmid/realmid.gno
)

// Returns the identifier of the previous realm in the call chain.
func Previous() string {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggestion: nothing in the tree imports realmid since basedao stopped, and README.md:21-32 heads a block "Not for caller authentication". Previous and Current still freeze at a published path as bare stack walks; publishing only IsPackage and IsUser would leave nothing to reach for by mistake.

Comment thread gno/p/basedao/basedao.gno
Comment on lines 308 to 310
if len(vote) > 16 {
panic("invalid vote")
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggestion: only the length is checked, so a member who sends YES has it stored and counted in the ballot total while every tally reads 0/3. Pre-existing, raised because 8c8ef04 typed the three constants so a misuse is a compile error, and a runtime value cannot be typed after publication.

@davd-gzl

davd-gzl commented Jul 27, 2026 •

Copy link
Copy Markdown
Collaborator

I think we can refactor the avl.Get instead of copying the avl library into our namespace. We shouldn't have any issue.
I will do a PR

@davd-gzl davd-gzl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Outside of this PR + comments above this looks good to merge to me

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