Skip to content

test(state): non_admin_set_profile_is_accepted regression after #505 membership gate #565

@intendednull

Description

@intendednull

caveman bug. test fail since #505 (commit 8c40e32 fix(state): gate Pin/Unpin/Set/UpdateProfile on membership).

Repro

$ cargo test -p willow-state non_admin_set_profile_is_accepted
thread panicked at crates/state/src/tests/materialize.rs:67:5:
assertion `left == right` failed
  left: None
 right: Some("Alice")

Root cause

Test emits two events via do_emit (crates/state/src/tests/materialize.rs:25):

  1. admin's GrantPermission { peer_id: alice, permission: SendMessages }
  2. alice's SetProfile { display_name: "Alice" }

do_emit always passes deps: vec![]. Cross-author causal linkage absent. Per-author seq chains both authors separately but doesn't link admin's grant to alice's set-profile.

Pre-#505: SetProfile had no membership gate → order-of-application irrelevant → test passed.

Post-#505: SetProfile rejected if author not yet in state.members. topological_sort tiebreaker happens to apply alice's SetProfile BEFORE admin's GrantPermission → membership check fails → silent reject → state.profiles.get(alice) returns None.

Two valid fixes

A. Test-side: thread the grant event's hash into SetProfile's deps so causal ordering is forced. Minimal, isolated. But same shape exists in 4+ other tests (grep do_emit.*SetProfile).

B. Production-side: have apply_event buffer events whose author membership isn't yet established, retry on later GrantPermission. Mirrors PendingBuffer's prev-chain handling. Bigger refactor but resolves the same shape for real-world out-of-order delivery.

Skill: ambiguous-fix-path; design call needed. Coordinator-flagged + filed during run that exposed it (auto-fix batch claude/friendly-maxwell-M5xB6).

Sites

  • crates/state/src/tests/materialize.rs:43 — failing test
  • crates/state/src/tests/materialize.rs:25do_emit helper (always deps: vec![])
  • crates/state/src/materialize.rs:548-555SetProfile membership gate (introduced auto-fix batch claude/friendly-maxwell-EjeTz (2026-05-01) #505)
  • commit 8c40e32 — origin

Run notes

Surfaced by 2 implementer agents in this session (#550 + #520) running cargo test -p willow-state. Reproduced from coordinator HEAD before filing — not a sandbox flake.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions