Repository navigation
feat(id): store-wired writer-set expansion — expand/expand_retro over the membership layer (#4998) - #6787
Conversation
… the membership layer (#4998) Spec §9 item 2 (slice 2 of #3789). Adds Membership::members_at_position(+_shared) in id-core — the frontier-pinned enumeration counterpart of access_at_position, key members only (one-level flattening, §D4) — and idset::expand::Expander, which resolves each referenced group at the set version's pinned frontier under its resolution state R, caches it under the §4.5 key (group, frontier, R), and delegates entry semantics to view::expand_set. expand/expand_retro return authors only; exclusions are applied by filtering the admitted set through ExpandedWriters::contains (the raw explicit_authors set does not subtract exclusions). A public admission cannot be materialized as a set of authors and is refused with ExpandError::PublicEntry. The idset module doc no longer states expansion is absent. Tests: pkgs/id/tests/writer_set_expansion.rs carries spec tests 1-7 (order-independence, frontier-pinning, reproducibility against a later membership event, retro subset + empty-without-history, fork-invalidated grant + cache key on R, role_min at the frontier, exclusion wins + never-admitted no-op) plus the public refusal. cargo test -p id -p id-core: 3179 passed, 0 failed.
|
Warning Review limit reachedYou'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 31 minutes. View limit details
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. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d19a9021ca
ℹ️ 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".
| #[test] | ||
| fn test_expand_is_order_independent() { |
There was a problem hiding this comment.
Cover expansion invariants with generated property tests
The new suite checks order independence, frontier pinning, and expand_retro(v) ⊆ expand(v) only with fixed examples; existing property suites do not exercise the new expansion APIs. The root AGENTS.md testing doctrine explicitly requires property tests for meaningful invariants and says examples do not replace them. Add generated entry permutations, role/history/exclusion combinations, and causal histories that check these guarantees against the declared oracle.
AGENTS.md reference: AGENTS.md:L41-L45
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 9e0e5f4. Added a proptest property suite at the end of pkgs/id/tests/writer_set_expansion.rs (128 cases each), with the oracle for each property stated in its comment per the testing doctrine:
prop_expand_is_order_independent— generated entry/exclusion lists (key/group/public shapes, generatedrole_minandinclude_history) expand identically under permutation, including refusing identically;prop_expand_retro_is_subset_of_expand— the retro subset invariant over generated sets;prop_expand_is_frontier_pinned_under_generated_history— a generated add/remove/promote history chained after the pin never moves the pinned expansion; oracle is the expansion evaluated before the history is appended.
The seven spec tests remain as the named example/acceptance tests. Suite: writer_set_expansion 13/13, writer_set_projection 4/4.
| let members: BTreeMap<AuthorKey, Role> = self | ||
| .membership | ||
| .members_at_position(&version.frontier, group)? | ||
| .into_iter() | ||
| .map(|(author, access)| (author, access_role(&access))) |
There was a problem hiding this comment.
Preserve administrator roles before applying role_min
For a group entry with role_min: Role::Admin, this mapping assigns every administrator Role::Manage, so view::role_at_least rejects all of them because Manage < Admin. Consequently, administrator-only admissions always expand to an empty set, and administrator-only exclusions silently exclude nobody. The groups fold preserves this distinction by consulting record.admins before falling back to access_role (groups/fold.rs:1512–1516); expansion likewise needs the administrator metadata resolved at the pinned frontier rather than access levels alone.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 9e0e5f4, with one deliberate approximation. You're right that the layer-backed snapshot topped every admin out at Manage, so an Admin threshold admitted nobody.
What the wiring can and cannot know: expand resolves groups through the membership layer (§4.5's sanctioned entry points), and that layer records Admin as Manage — the fold keeps Admin apart in record.admins precisely because the layer has no Admin bit. So the fix evaluates an Admin role_min at Manage (clamp_admin_thresholds in idset/expand.rs): admins are admitted instead of nobody, pinned by test_expand_role_min_admin_is_answered_at_manage_the_layers_top_role.
The remaining inexactness — a non-admin manager also passes an Admin threshold — needs the fold's admin-at-frontier state plumbed into expansion, which no caller can supply to the layer today. That's filed as #6798 with the design sketch, and the limitation is stated in the expand module doc rather than hidden.
| if admits_public(set, retro) { | ||
| return Err(ExpandError::PublicEntry); | ||
| } |
There was a problem hiding this comment.
Honor public exclusions before refusing materialization
For the supported emergency-stop configuration entries = [Public], excludes = [Public], this early return produces ExpandError::PublicEntry even though exclusions make the result the finite empty set. The existing projection explicitly supports this case (view::test_public_exclusion_admits_nobody), and the writer-set design §D6 requires its expansion to be empty. Check for the public exclusion before refusing a public admission so both expand and history-enabled expand_retro can return the correct empty result.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 9e0e5f4. expand_narrowed now checks for a public exclusion before the public-admission refusal: the §D6 emergency stop makes the expansion the finite empty set, so expand and expand_retro return Ok(empty) for entries = [Public], excludes = [Public] (and for named admissions under a public exclusion). Pinned by test_expand_public_exclusion_admits_nobody_not_refused. A public admission with no public exclusion still refuses with PublicEntry, since that expansion genuinely cannot be materialized as a set of authors.
…sion empty set, Admin threshold at Manage P1: proptest property suite for the expansion invariants (order-independence over generated entry/exclusion permutations, expand_retro subset, frontier-pinning under generated add/remove/promote histories), each with its oracle stated. P2a: a public exclusion (the §D6 emergency stop) now yields the finite empty set instead of ExpandError::PublicEntry. P2b: role_min Admin is evaluated at Manage — the membership layer records Admin as Manage, so admins are admitted instead of nobody; the approximation (non-admin managers also pass an Admin threshold) is documented in the module doc and pinned by test_expand_role_min_admin_is_answered_at_manage_the_layers_top_role. Targeted: writer_set_expansion 13/13, writer_set_projection 4/4.
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Closes #4998 (writer-set spec §9 item 2, slice 2 of #3789).
Implements the store-wired expansion lane code-c's triage on #4998 routed: PR #6672 (for #5545) landed the snapshot-level
view::expand_set, but the acceptance API —expand(set_version)/expand_retro(set_version)expanding throughis_member_at/access_at_positionpinned to the set version's frontier — plus spec tests 1–7 and theidset.rsmodule-doc update were still unbuilt.What changed
id-coremembership layer —Membership::members_at_position+members_at_position_shared: the frontier-pinned enumeration counterpart ofaccess_at_position(mirrorsmanagers_at_position). Returns key members only, sorted — group-valued members are not followed, which is the one-level flattening of §D3/D4. Never reads the livemembers(group)roster.idset::expand(new) —Expanderover aMembershiplayer +SetVersion { set, frontier, resolution }:Rolethe way the groups fold does (Admin shows as Manage — the layer records it apart), caches resolutions under the §4.5 key(group, frontier, R), and delegates entry semantics (one-level groups,role_min, exclusions-win, per-entryinclude_history) toview::expand_set;expand/expand_retroreturnBTreeSet<AuthorKey>— authors only, no counting path;ExpandedWriters::contains— the first test run caught thatexplicit_authors()alone does not subtract exclusions;Publicadmission cannot be materialized as a set of authors, so it is refused withExpandError::PublicEntryinstead of silently returning only the named authors (callers needing the public shape useview'sExpandedWriters).idset.rsmodule doc — no longer states expansion is absent; it points atexpand/viewbeside the types.pkgs/id/tests/writer_set_expansion.rs: spec tests 1–7 named as such (order-independence; frontier-pinning; unchanged by a later group-membership event, recomputed with a fresh expander against a changed live roster;expand_retro ⊆ expandper entry + empty retro with no history entries; fork-invalidated grant changes the expansion — fed asRole::Otherexactly asevent_store/resolve.rsfeeds fork-excluded actions — and the cache keys onRviacache_entries();role_minat the frontier vs after a later promotion; exclusion removes an admitted writer and a never-admitted exclusion is a no-op), plus the public-entry refusal. Oracle: the membership layer fed a known causal history (per the testing doctrine, each test names its oracle in the file header).Verification
cargo test -p id --test writer_set_expansion --test writer_set_projection— 8/8 + 4/4.cargo test -p id -p id-core(laptop) — 3179 passed, 0 failed, 33 ignored, 50 test binaries. (A comment-ordering fix inlayer.rslanded after that run; it touches no code.)🤖 Queue worker lane code-t, fallback mode (queue backend down, #6619).
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.