-
Notifications
You must be signed in to change notification settings - Fork 19
fix: getAuthChain including the event itself #193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Warning Rate limit exceeded@ggazzo has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 1 minutes and 32 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughThe auth chain computation was adjusted to exclude the starting event from its own chain. The difference calculation now explicitly appends the current event ID when building per-state chains. A cached-chain return path was tightened with a non-null assertion. No public signatures changed. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Caller
participant Definitions as definitions.ts
participant Cache as AuthChainCache
participant Store
Note over Caller,Definitions: Compute auth chain for an event (starting event excluded)
Caller->>Definitions: getAuthChain(event, store)
alt Cached
Definitions->>Cache: lookup(event.id)
Cache-->>Definitions: authChain (ancestors only)
Definitions-->>Caller: authChain
else Not cached
rect rgba(200,220,255,0.25)
Note right of Definitions: _getAuthChain(event, acc = ∅)
loop Traverse ancestors
Definitions->>Store: fetch auth events
Store-->>Definitions: parent events
Definitions->>Definitions: add parents to acc
end
end
Definitions-->>Caller: acc (ancestors only)
end
sequenceDiagram
autonumber
participant Caller
participant Definitions as definitions.ts
Note over Caller,Definitions: Build per-state chains for difference calculation
Caller->>Definitions: getAuthChainDifference(stateEvents, store)
loop For each event in state
Definitions->>Definitions: chain = await getAuthChain(event, store)
Note right of Definitions: Excludes starting event by design
Definitions->>Definitions: perState = [...chain, event.eventId]
end
Definitions-->>Caller: Difference result derived from perState sets
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #193 +/- ##
=======================================
Coverage 80.41% 80.42%
=======================================
Files 58 58
Lines 4514 4516 +2
=======================================
+ Hits 3630 3632 +2
Misses 884 884 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/room/src/state_resolution/definitions/definitions.ts (2)
104-106: Avoid non-null assertion; prefer a guarded read for clarity.Behavior is unchanged, but this reads cleaner and satisfies strict linters without
!.- if (eventIdToAuthChainMap.has(eventId)) { - return eventIdToAuthChainMap.get(eventId)!; - } + const cached = eventIdToAuthChainMap.get(eventId); + if (cached) { + return cached; + }
152-156: Including the event ID in per‑state chains is correct; streamline the loop and replace TODO.Avoid the temporary array and make the intent explicit.
- // TODO: deb check this I changed to keep the function behaving as the spec - for (const authChainEventId of [ - ...(await getAuthChain(event, store)), - event.eventId, - ]) { - authChainForState.add(authChainEventId); - } + // Includes the event itself per spec (see NOTE link above). + for (const id of await getAuthChain(event, store)) { + authChainForState.add(id); + } + authChainForState.add(event.eventId);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/room/src/state_resolution/definitions/definitions.ts(3 hunks)
🔇 Additional comments (1)
packages/room/src/state_resolution/definitions/definitions.ts (1)
132-132: Auth chain should exclude the starting event — verify downstream callers/testsMatches the spec (ancestors-only). Found call sites to verify/update:
- packages/room/src/state_resolution/definitions/algorithm/v2.ts — calls getAuthChain(event, wrappedStore) and iterates authChain; confirm it doesn't rely on the event being included.
- packages/federation-sdk/src/services/send-join.service.ts — calls getAuthChain(event, stateService._getStore(roomVersion)); confirm expectations for send-join.
- packages/room/src/state_resolution/definitions/definitions.ts — caller explicitly appends event.eventId after getAuthChain (already compensates).
Verify tests and callers that assumed the old behavior and adjust as needed.
ac21e3f to
4a41834
Compare
extracted from #171
Summary by CodeRabbit