Repository navigation
id: add append admission state machine - #12932
Conversation
|
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 14 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: 0fdb12e9e3
ℹ️ 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".
| return false; | ||
| } | ||
| match policy.rule { | ||
| AdmissionRule::OwnerOnly => policy.admins.contains(signer), |
There was a problem hiding this comment.
Distinguish the owner from group administrators
With AdmissionRule::OwnerOnly, any signer in policy.admins is directly accepted, exactly as with AdmissionRule::Admins. The existing enum explicitly defines OwnerOnly as accepting only the owner, so an administrator who is not the owner can bypass moderation under this policy. Carry the owner identity separately and compare against it for this rule.
Useful? React with 👍 / 👎.
| if !eligible(policy, &pending.signer) { | ||
| return Err(AdmissionError::NotEligible); | ||
| } |
There was a problem hiding this comment.
Check reviewer eligibility separately from direct admission
For a non-group submitter on an open attribute, submit correctly creates a pending item, but this check prevents anyone from approving it unless the submitter first becomes eligible for direct acceptance. AdmissionRule is documented as controlling direct acceptance, and design §6.2 permits non-group submissions through member/admin approval. Approval needs a separately authorized reviewer rather than requiring the original signer to satisfy the direct-admission rule; otherwise the advertised moderation path cannot publish external submissions.
Useful? React with 👍 / 👎.
| let pending = self | ||
| .pending | ||
| .remove(&PendingId::from(id)) | ||
| .ok_or(AdmissionError::NotFound)?; | ||
| self.accepted.push(pending.id); |
There was a problem hiding this comment.
Reject approval after the attribute has been closed
If a member submits while the attribute is moderated and the owner subsequently changes its mode to Closed, approve still removes the pending item and appends it to the accepted list. This method never examines policy.mode, although it receives the current policy and promises to recheck it. Check the current append mode before committing acceptance so closing an attribute also prevents pending submissions from being appended.
Useful? React with 👍 / 👎.
| let pending = PendingId::from(submission.id.as_str()); | ||
| return if self.pending.contains_key(&pending) { | ||
| Ok(AdmissionOutcome::Pending(pending)) | ||
| } else { | ||
| Ok(AdmissionOutcome::Accepted) |
There was a problem hiding this comment.
Resolve idempotent retries using the original submission identity
When a pending submission is retried with the same idempotency key and bytes but a different id, this branch looks up the retry's ID and returns Accepted even though the original submission is still pending and nothing was accepted. AttributeSubmission exposes these fields independently, and this API neither validates their binding nor retains the original ID in the idempotency record. Store the original submission identity alongside the bytes and return its actual state, or reject inconsistent identities.
Useful? React with 👍 / 👎.
| //! Model-based oracle for A-GRAPH-9127-02 (#10237). | ||
| //! | ||
| //! The model says invalid signatures never enter either state; open attributes | ||
| //! still hold non-group submissions in Pending; approval rechecks current | ||
| //! membership and revocation; idempotency keys conflict on different bytes; | ||
| //! and accepted order is append-only. |
There was a problem hiding this comment.
Exercise admission transitions with a generated reference model
This suite describes itself as model-based, but all four tests are fixed examples against the implementation; there is no independent transition model or generated command sequence. The repository's testing doctrine explicitly requires PBT for state-machine invariants and MBT where a specification exists. Add a reference model and generate submit, approve, retry, and policy-change sequences, comparing results and state after each operation; the current examples do not exercise successful approval or interacting transitions.
AGENTS.md reference: AGENTS.md:L36-L39
Useful? React with 👍 / 👎.
Refs #10237
Summary
Evidence
cargo test -p id-events --test append_list_state_machinerustfmt --checkandgit diff --checkpassMerge Danger
Low-to-medium. This is the approved append-admission slice; it leaves tenant/membership authority as policy input and does not perform production rollout.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.