GeezerVison is showing github.com — fix(id/groups): let the membership layer arbitrate removals tangled in concurrent removals (#3787) by dezren39 · Pull Request #3871 · developing-today/code
Conversation
dezren39
commented
Nov 1, 2026
•
edited by blacksmith-sh
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
What
Fixes #3787: voiding_scenarios fails 3 of 12 in the id package's nix checkPhase at main — test_s2_mutual_removal_removes_both, test_s2_concurrent_re_add_is_voided, test_s2_three_cycle_removes_every_member — which cascades to the toplevel and blocks nixos-rebuild switch (and with it the code#3720 fold activation).
One file changes: pkgs/id/src/groups/fold.rs (+56/−2).
Root cause
Not a sandbox/environment effect: the same three tests fail identically under a host cargo test on the laptop, at the identity arrival order. It is a logic divergence introduced when #3725 wired the groups fold into the event store's resolution as a gate and roster source.
The fold's member judge (Engine::member) evaluates a removal against the state built by the canonically earlier events. For removals tangled in concurrent removals, that sequential view is the wrong one — the membership layer is the design's authority on strong-remove concurrency (resolve.rs rule 2: it judges authority at an operation's causal position, with the resolver's mutual-removal exemption and cycle handling), and it passes these exact scenarios standalone (membership_scenarios). Measured fold verdicts for the failing scenarios:
- Mutual removal — B's removal of A:
Refused(NotActive), because A's concurrent removal of B had already committed in canonical order. Fold roster {A, C} instead of {C}.
- Three-cycle — C's removal of A:
Refused(NotAdmin), the creator-Admin policy firing on an author whose standing is a concurrent-removal tangle. Fold roster {A, C} instead of {}.
- Concurrent re-add — C's removal of B:
Refused(NotAMember), because A's concurrent removal of B struck first; that refusal then poisoned the dependent re-add's frontier in the fold's own layer (Membership(Invalid("attempted to add a member who is already active"))). Fold verdict for A's removal also fed back into the store layer, flipping applied flags.
Fix
In Engine::member, a removal in a non-friendship group whose author or target is named by another removal concurrent with it — neither in the other's causal past — is handed to the membership layer as a plain decision, with none of the judge's current-state pre-checks (NotActive / NotAMember / NotManager / NotAdmin). The layer arbitrates the tangle. manage_chain still applies afterwards (it already judges at the event's position).
The discriminator is true concurrency, so the pinned #168 policy behaviors are untouched:
- A manager's unilateral removal of an Admin is still refused (the Admin's answering removal is causally later, not concurrent) —
test_a_fold_refused_removal_does_not_strip_the_admins_authority and the rest of the ingest gate tests pass.
- Role changes stay Admin-only; friendships keep their dissolve path (deferral is scoped to non-friendship groups).
Verification (host, laptop)
cargo test --test voiding_scenarios: 12 passed, 0 failed (was 9/3).
cargo test --lib: 1678 passed, 0 failed — includes the groups fold/delegation/friendship suites and the event-store fold-gate tests.
cargo test --test membership_scenarios --test voiding_properties --test production_ingest --test content_removal: all pass.
cargo fmt --check: the changed file is clean.
- Nix build of
#id-web with checkPhase: verification in progress on the laptop; results will be posted here and on build(id): voiding_scenarios tests fail at main — nixos-rebuild switch cannot complete (blocks code#3720 fold) #3787 (build run twice, the failure class is concurrency-flavored).
![Autofix with [code]smith](/api/image?u=https%3A%2F%2Fcamo.githubusercontent.com%2F33b6f70f3541c4e93f4503d29cbfec051fa1b040d8e0ae9313a51c4ece44a627%2F68747470733a2f2f70722d636f6d6d656e74732d6173736574732e626c61636b736d6974682e73682f636f6465736d6974682f6175746f6669782d776974682d636f6465736d6974682d6461726b2d33782e706e67)
Need help on this PR? Tag @codesmith-bot with what you need.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…n concurrent removals (#3787)
Since the groups fold was wired into the event store's resolution
(#3725), its member judge has pre-empted the membership layer on
concurrent removals: it judges a removal against the state built by
the canonically earlier events, so the second half of a concurrent
removal tangle is refused by whichever side the ID order struck
first — NotActive for a removed author (mutual removal), NotAdmin
for a removal of the creator by a concurrently removed manager
(three-cycle), NotAMember for a target a concurrent removal already
struck (concurrent re-add, whose refusal then corrupts the dependent
re-add's frontier in the fold's own layer). The fold's roster and
voiding verdicts then disagree with the S2 outcomes the membership
layer reaches on its own, and voiding_scenarios fails 3 of 12 in the
nix build's checkPhase, blocking nixos-rebuild switch.
A removal in a non-friendship group whose author or target is named
by another removal concurrent with it — neither in the other's
causal past — is now handed to the membership layer with none of the
judge's current-state pre-checks; the layer judges authority at the
operation's position and arbitrates the tangle. Unilateral removals
keep every existing check: a manager's removal of an Admin is still
refused, because the Admin's answering removal is causally later,
not concurrent.
Warning
Review limit reached
You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.
Next included review available in 40 minutes.
Check out review usage here.
View limit details
-
Limit details: You’ve used the included review currently available.
Learn how review limits work.
Review configuration:
Run configuration
-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: defaults
- Review profile: CHILL
- Plan: Advanced
- Run ID:
86f359c3-2083-4199-963a-224751460ce7
Commits
-
Reviewing files that changed from the base of the PR and between 064ce9e and fea193a.
Files selected for processing: 1
-
pkgs/id/src/groups/fold.rs
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
-
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Codex Review Summary
This comment shows the latest Codex review activity on this pull request.
| Review |
Status |
Commit |
Review trigger |
| 📝 Code Review |
✅ Completed 2026-11-01T17:21:07.971737Z |
fea193a |
PR opened |
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review" or "@codex security review".
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fea193a497
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+934
to
+935
|
|
if entangled {
|
|
|
return Ok(Decision {
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preserve Admin protection for concurrent removals
When two non-Admin managers concurrently remove the same Admin, removal_entangled returns true for both because they share a target, and this early return bypasses the NotAdmin guard below. Neither downstream layer restores that protection: manage_chain checks only Manage authority, and the membership layer represents Admin as Manage (access_level/access_for). Consequently, managers can remove an Admin simply by issuing concurrent removals, even though either removal alone is forbidden. Preserve the Admin-versus-manager restriction at the operation's causal position instead of dropping it for every entangled removal.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+1021
to
+1022
|
|
&& !causal_past(by_id, &other.after).contains(&event.id)
|
|
|
&& matches!(removed_member(other), Some(target) if target == event.author || target == member)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filter removal candidates before traversing their ancestry
For a group with one early removal followed by N causally chained policy events, this predicate rebuilds the complete causal past of every subsequent policy event before checking whether it is even a removal. Those descendants pass !past.contains(&other.id) because past belongs to the earlier removal, and causal_past traverses the whole chain before testing containment. This adds approximately N²/2 ancestor visits per fold round—about 50 million for 10,000 later events—even though there are no other removals to entangle. Check removed_member(other) and the matching target before computing its ancestry so unrelated group events do not introduce this quadratic replay cost.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Nix verification complete — both runs green
Pre-existing red checks (unchanged by this PR, no findings in groups/fold.rs): id-clippy-lint fails at main on deny-level lints in web/markdown.rs:311, web/world_ws.rs:208, world/tests.rs:1569, web/identity.rs:984 (tracked in #2401); id-rustfmt-check reports diffs in 16 files at main, none of them touched here.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 1, 2026
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|