Skip to content

Fix pear#147 lost-steer duplicate delivery drop#157

Merged
kjgbot merged 1 commit into
mainfrom
pear-147-lost-steer-dedupe
Jun 8, 2026
Merged

Fix pear#147 lost-steer duplicate delivery drop#157
kjgbot merged 1 commit into
mainfrom
pear-147-lost-steer-dedupe

Conversation

@kjgbot
Copy link
Copy Markdown
Contributor

@kjgbot kjgbot commented Jun 8, 2026

Summary

  • Fixes pear#147 lost-steer / steer-to-PTY drop for Slack integration events where a human message could be logged as received/injecting, then later replays were skipped as duplicates before the intended session received it.
  • Tracks provisional dedupe claims as in-flight immediately after claim, commits only after confirmed delivery_injected, and releases on reject or bridge-owned timeout for silent no-settle.
  • Makes duplicate replays wait for the pending claim outcome: committed claims suppress real duplicates; released claims re-drive delivery.
  • Moves eventsInjected telemetry for concrete-agent delivery from send-accepted to confirmed injection and surfaces skipped duplicate paths through aggregated warnings.

Repro Evidence

  • Live Slack thread replies 1780892351_382129 and 1780893336_601259 were logged as received -> injecting -> skipped duplicate path, but never reached slack-comms.
  • Root cause: the content-aware Slack dedupe claim was taken before confirmed injection; if injected confirmation never settled, the claim stayed provisional until TTL and identical-content file revs were dropped as duplicates.

Claim Lifecycle

  • claim -> provisional and tracked in inFlightDedupeClaims.
  • delivery_injected confirmed -> commit claim and increment eventsInjected.
  • send reject / injected-confirmation reject / bridge timeout -> release claim.
  • replay collision while pending -> await pending outcome; re-drive if released, suppress if committed.

Tests

  • node --experimental-strip-types --no-warnings --test src/main/__tests__/integration-event-bridge.test.ts -> 63/63 passed
  • npm test -- src/main/__tests__/integration-event-bridge.test.ts -> 94/94 passed
  • git diff --check -- src/main/integration-event-bridge.ts src/main/__tests__/integration-event-bridge.test.ts -> clean

Notes

  • npx tsc --noEmit --project tsconfig.node.json is currently blocked by existing repo-wide TypeScript baseline issues; pear-worker is verifying the clean-main baseline separately per project-lead.

@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Jun 8, 2026

Your free trial PR review limit of 300 PRs has been reached. Please upgrade your plan to continue using CodeAnt AI.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 8, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 111369c0-33d1-42aa-8bb4-c18b29b01371

📥 Commits

Reviewing files that changed from the base of the PR and between d2449ff and a6738e4.

📒 Files selected for processing (2)
  • src/main/__tests__/integration-event-bridge.test.ts
  • src/main/integration-event-bridge.ts

📝 Walkthrough

Walkthrough

Integration event bridge now tracks in-flight dedupe claims to allow retrying suppressed duplicate injections when the prior delivery result is unresolved or released. Injected confirmation handling supports configurable timeout via environment variable with proper timer cleanup. Tests verify replay behavior when injected delivery times out.

Changes

Injected Delivery Timeout and Dedupe Retry

Layer / File(s) Summary
Types and Timeout Infrastructure
src/main/integration-event-bridge.ts
Introduces DEFAULT_DELIVERY_INJECTED_CONFIRMATION_TIMEOUT_MS constant, DeliveryDedupeClaimOutcome and InFlightDedupeClaim types, and deliveryInjectedConfirmationTimeoutMs() and withTimeout() helpers for environment-driven confirmation timing and promise timeout racing with cleanup.
In-flight Dedupe Storage and Coordination
src/main/integration-event-bridge.ts
Adds inFlightDedupeClaims map to bridge instance and implements trackInFlightDedupeClaim() and waitForInFlightDedupeClaims() helpers to track new claims and await their settlement outcome.
Duplicate Rejection with In-flight Claim Retry
src/main/integration-event-bridge.ts
Updates Slack logical and non-Slack recent-injection duplicate rejection paths to wait for in-flight dedupe claims on the same key; retries injection if prior claim was released, otherwise marks dropped and reports skipped duplicate.
Injection Completion with Claim Settlement
src/main/integration-event-bridge.ts
Tracks dedupe claims during injection by creating inFlightClaim handles and settles them as committed after injected confirmations resolve and dedupe key is committed, or released on confirmation failure or when no recipients succeed. Centralizes skipped-duplicate warning via new reportSkippedDuplicatePath() helper.
Broker Message Timeout with Configurable Duration
src/main/integration-event-bridge.ts
Updates sendBrokerMessage() waitForInjected behavior to use environment-driven deliveryInjectedConfirmationTimeoutMs() and withTimeout() for proper timer cleanup and clear timeout error messaging.
Test Setup and Replay Scenario Coverage
src/main/__tests__/integration-event-bridge.test.ts
Clears PEAR_INTEGRATION_EVENT_INJECTED_CONFIRMATION_TIMEOUT_MS in test beforeEach for determinism. Adds new test verifying Slack replay can re-drive after injected delivery timeout releases. Updates telemetry assertion in delivery-failure test to expect eventsInjected: 0.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

  • AgentWorkforce/pear#147: Directly implements the in-flight dedupe claims and confirmation timeout/release flow described in this issue to allow re-drives when injected deliveries never confirm.

Possibly related PRs

  • AgentWorkforce/pear#148: Implements the same injected delivery confirmation flow with in-flight dedupe claim tracking, timeout behavior, and replay/retry test coverage in the same files.
  • AgentWorkforce/pear#154: Also modifies integration-event-bridge.ts deduplication logic for Slack events; this PR adds in-flight dedupe claims and timeouts while the related PR adjusts Slack targeted context and candidate handling.

Poem

🐰 Dedupe claims in flight now soar,
When injections time out and locked doors
Release their grip—replays retry!
The broker's timeout, no longer shy,
Lets hung deliveries finally fly. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix pear#147 lost-steer duplicate delivery drop' directly references the main issue being fixed and accurately summarizes the primary change: resolving a duplicate delivery bug that caused Slack integration events to be lost.
Description check ✅ Passed The description provides comprehensive context about the fix, including the problem (lost-steer duplicate delivery drop), the solution approach (tracking provisional dedupe claims), and evidence of the issue with specific examples and test results.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pear-147-lost-steer-dedupe

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 and usage tips.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a mechanism to track in-flight event delivery deduplication claims and handle timeouts when waiting for broker delivery confirmations. Instead of immediately dropping duplicate events, the bridge now waits for any in-flight claims to settle; if a claim is released (e.g., due to a timeout), the event is retried. Additionally, a configurable timeout environment variable has been added along with corresponding integration tests. There are no review comments to address.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Copy link
Copy Markdown

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

Choose a reason for hiding this comment

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

No issues found across 2 files

Re-trigger cubic

@agent-relay-code
Copy link
Copy Markdown
Contributor

ℹ️ pr-reviewer: review only — no file changes were applied to the PR (nothing to commit after review). The notes below are advisory and were not pushed.

No code changes were needed after review. I validated the PR diff against the current checkout and found no demonstrated breakage.

Addressed comments

  • codeant-ai[bot]: raised only a trial-limit notice, not a code issue; no change needed.
  • coderabbitai[bot]: reported “No actionable comments”; its docstring coverage warning is advisory and not a failing required check for this focused PR, so no change needed.
  • gemini-code-assist[bot]: stated there were no review comments to address; no change needed.
  • cubic-dev-ai[bot]: reported “No issues found” across the changed files; no change needed.

Validation run:

  • node --experimental-strip-types --no-warnings --test src/main/__tests__/integration-event-bridge.test.ts passed, 63/63.
  • npm test passed, 94/94.
  • npm run build passed.
  • npm run verify:mcp-resources-drift passed.
  • GitHub API observed PR mergeable_state: clean; current head checks/statuses completed successfully.

@kjgbot kjgbot merged commit ee1e6c8 into main Jun 8, 2026
4 checks passed
@kjgbot kjgbot deleted the pear-147-lost-steer-dedupe branch June 8, 2026 07:36
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