Skip to content

docs: reflect atomic newer-wins store_received_tc_token - #380

Merged
jlucaso1 merged 2 commits into
mainfrom
claude/nifty-bohr-y7ih04
Jul 4, 2026
Merged

docs: reflect atomic newer-wins store_received_tc_token#380
jlucaso1 merged 2 commits into
mainfrom
claude/nifty-bohr-y7ih04

Conversation

@jlucaso1

@jlucaso1 jlucaso1 commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow-up docs update for oxidezap/whatsapp-rust#980, which:

  • Moved the tc-token newer-wins rule out of a Client-level tc_token_lock (which only serialized history-sync chunks against each other) and into store_received_tc_token itself, enforced atomically by each built-in backend (SqliteStore via an IMMEDIATE transaction, InMemoryBackend under its state lock).
  • This closes a cross-source race between history-sync candidates and the privacy-notification path, which no lock previously covered.

Changes

  • api/store.mdx — updated the store_received_tc_token doc comment to describe the newer-wins contract (byte-less placeholder or token_timestamp >= existing writes through, otherwise a no-op) and how the built-in backends enforce it atomically; updated the surrounding <Note> to warn custom-backend authors that a non-atomic override can still race two callers.
  • api/tctoken.mdx — reworded the "Incoming token notifications" steps (the privacy-notification path's own check is now a pre-filter for the presence re-subscribe, not the sole overwrite guard), added a paragraph pointing to the store-level newer-wins as what actually closes the cross-source race, and updated the sequence diagram's annotation on store_received_tc_token.
  • concepts/storage.mdx — updated the trait-summary comment for store_received_tc_token to mention the newer-wins semantics.

No changelog entries were added per instructions.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SxXWf7FV4PyphPKMQ4p9gD


Generated by Claude Code


Summary by cubic

Update docs to reflect atomic newer-wins enforcement in store_received_tc_token, closing the race between history-sync and privacy notifications. Clarifies that the notification pre-filter skips both storage and presence re-subscribe for stale tokens, updates the sequence diagram, and warns custom backends to use atomic upserts.

  • Migration
    • Custom backends should implement store_received_tc_token and touch_tc_token_sender_timestamp as atomic upserts that enforce newer-wins.

Written for commit 9754b3d. Summary will update on new commits.

…t#980)

whatsapp-rust#980 moved the tc-token newer-wins rule from a Client-level
tc_token_lock + get-then-store in history-sync into the store itself
(atomic in SqliteStore and InMemoryBackend), closing a cross-source race
with the privacy-notification path. Update the ProtocolStore trait docs
and the TC Token guide to describe the new atomicity guarantee instead
of the removed lock-based monotonicity guard.
@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@jlucaso1, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 38 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b15a837b-e638-43b4-b2f1-e81828035660

📥 Commits

Reviewing files that changed from the base of the PR and between e7f41b6 and 9754b3d.

📒 Files selected for processing (3)
  • api/store.mdx
  • api/tctoken.mdx
  • concepts/storage.mdx

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

Comment @coderabbitai help to get the list of available commands.

@mintlify

mintlify Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
whatsapp-rust 🟢 Ready View Preview Jul 4, 2026, 5:47 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Documentation-only updates to reflect atomic newer-wins semantics for tc-token storage. Minor rewording and annotations in sequence diagrams and comments.

Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Jul 4, 2026

Copy link
Copy Markdown

Greptile Summary

This is a documentation-only follow-up to whatsapp-rust#980, updating three .mdx files to reflect that the newer-wins tc-token guarantee is now enforced atomically inside store_received_tc_token itself rather than through an external client-level lock.

  • api/store.mdx: Expanded the store_received_tc_token doc comment with the full newer-wins contract (token_timestamp >= existing writes through; byte-less placeholder always replaced) and updated the <Note> to warn custom-backend authors that a non-atomic read-modify-write can still produce last-writer-wins corruption under concurrency.
  • api/tctoken.mdx: Replaced the ambiguous "monotonicity guard" wording in step 3 with a precise "pre-filter" description, added a paragraph explaining how the store-level atomic check closes the cross-source race between the privacy-notification path and history-sync, and updated the sequence diagram annotation.
  • concepts/storage.mdx: Updated the inline trait-summary comment for store_received_tc_token to mention newer-wins semantics and which built-in backends enforce it atomically.

Confidence Score: 5/5

Documentation-only change; no executable code is modified, and the docs are internally consistent.

All three files contain only prose and code-snippet illustrations. The newer-wins contract is described consistently across all changed files; the placeholder-always-replaced edge case is correctly called out in all relevant locations; and the sequence diagram accurately reflects the two-layer design (client pre-filter + atomic store check).

No files require special attention.

Important Files Changed

Filename Overview
api/store.mdx Adds newer-wins semantics detail to store_received_tc_token doc comment and expands the Note to warn custom-backend authors about the atomic-upsert requirement; no content issues found.
api/tctoken.mdx Rewrites step 3 with unambiguous pre-filter wording, adds a cross-source race explanation paragraph, and updates sequence diagram annotation; documentation is accurate and internally consistent.
concepts/storage.mdx Brief trait-summary comment updated to reflect newer-wins semantics and atomic backend enforcement; change is correct and consistent with the other two files.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant HS as History-Sync
    participant PN as Privacy-Notification
    participant Store as Store (SqliteStore / InMemoryBackend)

    Note over HS,PN: Cross-source race (now closed at store layer)

    HS->>Store: store_received_tc_token(jid, token_A, ts_A)
    PN->>Store: store_received_tc_token(jid, token_B, ts_B)

    Note over Store: Atomic newer-wins check inside each call
    Store-->>HS: "write-through if ts_A >= stored OR existing is placeholder"
    Store-->>PN: "write-through if ts_B >= stored OR existing is placeholder"

    Note over Store: No external lock required — both callers converge on the same atomic upsert
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant HS as History-Sync
    participant PN as Privacy-Notification
    participant Store as Store (SqliteStore / InMemoryBackend)

    Note over HS,PN: Cross-source race (now closed at store layer)

    HS->>Store: store_received_tc_token(jid, token_A, ts_A)
    PN->>Store: store_received_tc_token(jid, token_B, ts_B)

    Note over Store: Atomic newer-wins check inside each call
    Store-->>HS: "write-through if ts_A >= stored OR existing is placeholder"
    Store-->>PN: "write-through if ts_B >= stored OR existing is placeholder"

    Note over Store: No external lock required — both callers converge on the same atomic upsert
Loading

Reviews (2): Last reviewed commit: "docs: clarify tc-token pre-filter wordin..." | Re-trigger Greptile

Comment thread api/tctoken.mdx Outdated
"doesn't gate a presence re-subscribe on a newer real token" read as
the opposite of the intended behavior. A stale incoming token actually
skips both storage and the re-subscribe entirely.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

Auto-approved: Documentation-only changes across three .mdx files updating doc comments on tc-token newer-wins semantics, with no logic or source code changes. Low risk and safe to auto-approve.

Re-trigger cubic

@jlucaso1
jlucaso1 merged commit a5230fb into main Jul 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants