feat(context): introduce GroupRequest and ContextGroupId types for group management#2043
feat(context): introduce GroupRequest and ContextGroupId types for group management#2043
Conversation
There was a problem hiding this comment.
🤖 AI Code Reviewer
Reviewed by 3 agents | Quality score: 100% | Review time: 167.3s
💡 1 suggestions. See inline comments.
🤖 Generated by AI Code Reviewer | Review ID: review-3e67acf7
…isterFromGroup structure
There was a problem hiding this comment.
🤖 AI Code Reviewer
Reviewed by 3 agents | Quality score: 100% | Review time: 227.1s
💡 3 suggestions. See inline comments.
🤖 Generated by AI Code Reviewer | Review ID: review-078e5b50
There was a problem hiding this comment.
🤖 AI Code Reviewer
Reviewed by 3 agents | Quality score: 100% | Review time: 203.4s
💡 2 suggestions, 📝 1 nitpicks. See inline comments.
🤖 Generated by AI Code Reviewer | Review ID: review-86d4a70f
E2E Blockchain Proposals FailedThe following proposal workflow(s) failed:
Please check the workflow logs for more details. |
There was a problem hiding this comment.
🤖 AI Code Reviewer
Reviewed by 3 agents | Quality score: 100% | Review time: 197.8s
🟡 2 warnings, 💡 2 suggestions. See inline comments.
🤖 Generated by AI Code Reviewer | Review ID: review-04819256
…anced group management
…etaValue, GroupUpgradeValue, and GroupUpgradeStatus structures for enhanced group upgrade management
There was a problem hiding this comment.
🤖 AI Code Reviewer
Reviewed by 3 agents | Quality score: 89% | Review time: 319.2s
🟡 2 warnings, 💡 4 suggestions. See inline comments.
🤖 Generated by AI Code Reviewer | Review ID: review-f10665bd
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
…y is removed When the canary context is removed from the group between canary completion and propagator enumeration, the fresh enumeration yields N-1 contexts but the skip_context filter removes nothing (canary is gone). Starting completed at initial_completed=1 then produces completed=N which exceeds total=N-1, a logically invalid state. Check whether the canary was actually present in the fresh enumeration before counting it toward completed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
🤖 AI Code Reviewer
Reviewed by 3 agents | Quality score: 100% | Review time: 312.1s
🟡 2 warnings, 💡 6 suggestions. See inline comments.
🤖 Generated by AI Code Reviewer | Review ID: review-bbf56092
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Two fixes: 1. The retry loop checked `attempt >= MAX_AUTO_RETRIES` after incrementing, so only 2 retries (5s, 10s) ran instead of the documented 3 (5s, 10s, 20s). Changed to `attempt > MAX_AUTO_RETRIES`. 2. The manual retry handler could spawn a new propagator while the previous one was still sleeping in its exponential backoff, causing conflicting status writes and double-counted completions. Added an `active_propagators` guard to ContextManager that is set when a propagator is spawned and cleared when it finishes. The retry handler rejects requests while a propagator is active. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
There was a problem hiding this comment.
🤖 AI Code Reviewer
Reviewed by 3 agents | Quality score: 83% | Review time: 385.2s
🔴 2 critical, 🟡 3 warnings, 💡 5 suggestions. See inline comments.
🤖 Generated by AI Code Reviewer | Review ID: review-eac9a89c
[core] Implement hierarchical context group management
Description
Implements the full Context Groups feature across
core/crates/, enabling administrators to organize contexts into groups with shared application targets, coordinated upgrades, and membership management. Built across 6 phases on top of thecontext-configcontract types (ContextGroupId,GroupRequest,AppKey).Phase 1 — Storage Foundation
store/src/key/group.rs:GroupMeta(0x20),GroupMember(0x21),GroupContextIndex(0x22),ContextGroupRef(0x23),GroupUpgradeKey(0x24) — all withAsKeyParts/FromKeyPartsimpls and roundtrip testsGroupMetaValue,GroupUpgradeValue,GroupUpgradeStatuswith Borsh serializationprimitives/src/context.rs:UpgradePolicy(Automatic / LazyOnAccess / Coordinated),GroupMemberRole(Admin / Member),GroupInvitationPayloadPhase 2 — Group CRUD + Membership
group_store.rs(~390 LOC): Complete storage helper layer — CRUD for group metadata, members, context indices, and upgrade records with efficient key-only iteration for countingcreate_group,delete_group,add_group_members,remove_group_members,get_group_info,list_group_membersPhase 3 — Context-Group Integration
create_context.rs: Pre-validates group membership + app override; post-creation registers context in group indexdelete_context.rs: Unregisters context from group on deletionlist_group_contexts: New paginated endpoint for listing a group's contextsPhase 4 — Upgrade Propagation
propagate_upgrade(): Async fn that iterates group contexts, callsupdate_application()per context, persists progress after each stepGroupUpgradeStatus::InProgress { total, completed, failed }→Completed { completed_at }POST /upgrade,GET /upgrade/status,POST /upgrade/retryPhase 5 — Advanced Policies + Crash Recovery
execute.rstransparently upgrades stale contexts before method execution whenUpgradePolicy::LazyOnAccessis setContextManager::started()scans forInProgressupgrades and re-spawns propagatorsPhase 6 — Group Invitations + Join Flow
GroupInvitationPayload: Borsh-serialized + base58-encoded invitation token (mirrorsContextInvitationPayloadpattern)invitee_identity: Some) and open (invitee_identity: None) invitation modesPOST /groups/:id/invite,POST /groups/joinPost-implementation fixes (PR review)
propagate_upgradecompleted counter on retry/recovery pathsGroupContextIndexon re-registration, orphaned upgrade records on group deletion,Duration::newpanic on malformed Borsh, switched toValidatedJsonfor upgrade inputcount_group_admins/count_group_contextswithout Vec allocation, added offset/limit toenumerate_group_contexts, batched member cleanup in delete_groupGroupUpgradeValue/GroupUpgradeStatusstore types fromcalimero-context-primitivesAPI boundary — introducedGroupUpgradeInfoand primitives-localGroupUpgradeStatuswithFromconversion implscount_group_members()for efficient member counting, inlined value read inenumerate_in_progress_upgradesto reuse store handleNew API routes
Test plan
cargo check --workspace— compiles cleanlycargo fmt --check— no formatting issuescargo clippy -- -A warnings— no errorscargo test -p calimero-context— 16 tests passcargo test -p calimero-context-primitives— 3 tests passcargo test -p calimero-store— key roundtrip + value serialization tests passmeroctlagainst a runningmerodnodecontracts/repoDocumentation update
N/A — these are internal protocol types. Public API documentation should be added once the full group management feature is shipped end-to-end.
Note
High Risk
High risk because this introduces new persistent
Storecolumn/keyspace for groups, adds new admin API surface, and changes runtime execution to optionally perform lazy upgrades before method execution; mistakes could impact upgrade safety and context availability.Overview
Adds Context Groups as a first-class feature: new
ContextGroupId/AppKeytypes andGroupRequestcontract/config structs, plus node-side group CRUD, membership management, and context↔group indexing stored in a newStoreColumn::Groupkeyspace.Introduces group-wide application upgrade orchestration (canary + propagator with progress tracking, auto-retry/backoff, manual retry, and crash recovery on startup) and a LazyOnAccess policy that can trigger a context
update_applicationbefore executing user methods.Extends the admin server with
/groups/*endpoints (create/delete/info, members, contexts, upgrade/status/retry, invite/join) and integrates group membership into context lifecycle (optionalgroup_idon create with app-target override + membership checks, unregister on delete). Also hardens store iteration to skip mismatched-size keys when multiple key types share a column.Written by Cursor Bugbot for commit e5643bf. This will update automatically on new commits. Configure here.