Skip to content

refactor(slack): consolidate deferred ingress settlement - #130367

Merged
steipete merged 1 commit into
mainfrom
codex/loc-sweep-slack-deferred-20260826
Aug 26, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/loc-sweep-slack-deferred-20260826

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Slack's deferred ingress used three handwritten promise factories and overlapping completion flags to express the same lifecycle. That duplication made it harder to verify the crucial distinction between session ordering and channel-ID migration fencing after #114552.

Why This Change Was Made

Reuse the existing Plugin SDK deferred primitive, already used by Slack slash dispatch. One adoption-pending fact replaces overlapping flags; one terminal abort callback releases both latches and removes itself. Keep the latches separate: reply handoff releases session ordering, while adoption, abandonment, or abort releases the channel migration fence. Do not merge those ownership boundaries.

Production LOC: +20/-52 (net -32). Tests unchanged. No public SDK, config, database, protocol, dependency, or external Slack API change. This is a maintainer-requested behavior-preserving refactor, not a newly discovered Slack service bug.

User Impact

Independent Slack sessions still run concurrently; same-session turns retain FIFO ordering. Deferred replies do not let channel-ID migration overtake unfinished work. Relay dispatch completion and failure propagation remain unchanged.

Evidence

  • Exact candidate: 7195da4af690604c0eecd2a36dcb9f475dd3234d.
  • 57 existing tests in seven files pass on dependencies matching the candidate's package/lockfiles. The ingress suite uses actual Bolt and on-disk SQLite queues for active/deferred migration, session concurrency, FIFO, watchdogs, restart recovery, and dedupe.
  • Full selected changed gate passed, including types, typed lint, all guards, zero dead exports, and five doctor contract tests.
  • Fresh structured Codex P1 review and a separate independent source review passed on this exact commit. Direct dependency review confirms Bolt awaits listener completion through Promise.allSettled; the shared deferred primitive delegates to native Promise.withResolvers.
  • Proof is deterministic real-library/filesystem and queue-boundary testing, not a fresh authenticated Slack Desktop or service round trip. No Slack wire behavior changed.
OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs extensions/slack/src/monitor/ingress.test.ts extensions/slack/src/monitor/message-handler.test.ts extensions/slack/src/monitor/message-handler.debounce-key.test.ts extensions/slack/src/monitor/provider.ingress-start-cleanup.test.ts src/channels/message/ingress-drain-lifecycle.test.ts src/channels/message/ingress-drain.watchdog.test.ts src/channels/message/ingress-drain.cancellation.test.ts
node scripts/check-changed.mjs -- extensions/slack/src/monitor/ingress.ts extensions/slack/src/monitor/message-handler.ts

Maintainer-requested, AI-assisted. Required exact-head hosted CI and native landing checks remain mandatory.

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added channel: slack Channel integration: slack size: S maintainer Maintainer-authored PR labels Aug 26, 2026
@steipete
steipete marked this pull request as ready for review August 26, 2026 20:18
@steipete

Copy link
Copy Markdown
Contributor Author

Exact-head landing verification: Replace three handwritten deferred promises with the existing SDK primitive. Keep distinct session-handoff and channel-migration fences; one adoption flag and one terminal abort callback own settlement.

Production +20/-52 (−32); tests unchanged. 57 tests use actual Bolt App and on-disk SQLite ingress, same-session FIFO, independent sessions, migration, watchdog, cancellation and restart. Five doctor contract tests and the complete matching-dependency changed gate pass; fresh P1 and independent exact-head source review pass. Hosted CI is green for 7195da4.

Best-fix judgment: A single combined latch would incorrectly release channel migration at reply handoff. Existing SDK deferred helper is the canonical primitive; no new abstraction is necessary.

Limitations: This is behavior-preserving library/filesystem integration, not a new authenticated Slack Desktop run; Slack wire behavior is unchanged. Latest available ClawSweeper comment is a review-start placeholder, without an actionable rank-up list; independent final-source review is complete. No new config, dependency, protocol or database schema is introduced.

@steipete
steipete merged commit 6f37877 into main Aug 26, 2026
163 checks passed
@steipete
steipete deleted the codex/loc-sweep-slack-deferred-20260826 branch August 26, 2026 20:52
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: slack Channel integration: slack maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant