Skip to content

perf(connectors): keep one carried stamp per sender across failed starts - #48734

Merged
Jinwoo-H merged 1 commit into
mainfrom
perf/carry-one-stamp-per-sender
Nov 25, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
perf/carry-one-stamp-per-sender

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes STA-18126.

Summary

When a connector message fails to start (signed out, CLI missing, start failed), the conversation's next message carries it. Each carried card copied every earlier sender stamp with no de-duplication, so card n held n-1 stamps and total stamp storage grew quadratically with the length of a failed-start chain.

carriedMessages now keeps one stamp per sender, using the same key the authority check reads (source:userId:role, another app counted as app, an unnamed sender kept once). The first stamp for each sender is kept, so the sender order and the names of who typed are unchanged. Cards saved by earlier builds with repeated stamps are collapsed the next time they are carried, and they already read correctly because distinctAskers collapses them on read.

Performance

Measured with the real carriedMessages / carriedFields code, 366 B Slack stamp, 300 B of text per message:

N messages stamps on last card last card: stamps / whole body all cards: stamps / whole bodies CPU total
10 9 3.3 KB / 7.5 KB 17 KB / 42 KB 1.4 ms
100 99 36 KB / 73 KB 1.8 MB / 3.7 MB 7 ms
1000 999 367 KB / 732 KB 183 MB / 367 MB 615 ms

After this change each card holds at most one stamp per distinct sender, so stamp storage grows linearly (one sender: 1 stamp per card instead of n-1).

Testing

  • external-conversation-returned-carry.test.ts: 20 failed starts from one sender, and from two alternating senders, through the real journal writer; plus a saved card with repeated stamps. All three fail with the fix reverted.
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​35 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​35
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​26 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​18

@coderabbitai

coderabbitai Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The carried asker collection now keeps the first asker for each sender key, based on source, user ID, and app marker or role. Null askers share an empty key, so only the first is retained. Tests cover single and alternating senders across 20 failed starts, repeated senders in a saved card, and a trailing null entry.

Merge Risk: Minimal · up to d7238

Failed connector starts no longer cause carried sender stamps to grow quadratically. Each carried card keeps one stamp per sender, and authority behavior is preserved. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: carried stamps are reduced to one per sender across failed connector starts. It follows the conventional commit style and states the performance purpose. It matches th…
Description check Passed The description follows the repository template closely. It explains the mechanism (one stamp per sender keyed by source:userId:role, with app and unnamed-sender handling), the before and after, and t…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: carried stamps are reduced to one per sender across failed connector starts. It follows the conventional commit style and states the performance purpose. It matches the changeset, which de-duplicates carriedAskers and carriedMessages by sender.

Full details: Description check

Explanation

The description follows the repository template closely. It explains the mechanism (one stamp per sender keyed by source:userId:role, with app and unnamed-sender handling), the before and after, and the quadratic growth problem. It includes a Performance section with measurements and a Testing section that names the test file and its three cases. The Linked Issue section uses STA-18126 as a reference, but the template expects a 'Fixes #' issue link. Several template sections are missing or unfilled: ELI5, Visual Proof (required for behavior changes, or N/A with reason), Risk level and rollback plan, the testing checklist, and the Review and Agent skill sections. The description still covers most of the required content.

Resolution

Optionally add: an ELI5 summary; a Visual Proof entry (or N/A with reason); a Risk section with the Level and a rollback note (a plain revert is sufficient, but note that saved cards with duplicates are rewritten when carried); a GitHub issue link in the Linked Issue section in the 'Fixes #' form; and the Testing checklist items.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 96ee1964-a541-478f-a3e2-5294ff5efe53
Commits

Reviewing files that changed from the base of the PR and between 6e0e2d0 and d723851.

Files selected for processing: 2

  • src/main/external-conversations/external-conversation-returned-carry.test.ts
  • src/main/external-conversations/external-conversation-returned-carry.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@Jinwoo-H
Jinwoo-H merged commit 66654a9 into main Nov 25, 2026
54 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.

1 participant