feat(slack): implement Phase 1 bot behavior spec#242
Merged
hrygo merged 16 commits intohrygo:mainfrom Mar 8, 2026
Merged
Conversation
- Add owner definition and policy configuration - Unify decision flow diagram - Add DM behavior and edge cases - Clean up duplicate content - Consolidate configuration structure
- Add Owner policy config (owner_only, trusted, public) - Add ThreadOwnershipTracker for thread ownership management - Implement unified decision flow for message response - Support multi-owner threads via @mention - Add TTL expiration for thread ownership - Integrate ownership logic in events.go and socketmode.go Phase 1 MVP features implemented: - @mention detection and response - Owner policy configuration - Thread ownership tracking - Ownership transfer on @mention - Multi-owner support - TTL expiration Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Implement R5: ownership release when other bots mentioned - Add background cleanup goroutine for expired ownerships - Add Stop() method for graceful shutdown - Fix ownership tracking with context-based lifecycle Issues addressed: - P0: R5 rule implementation (ownership release) - P1: Memory leak prevention (periodic cleanup) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- R3: @mention transfers ownership (was of bot mentions) - R4: Multi-bot mention creates shared ownership - R5: @mentions excluding current owner releases ownership - Added human用户过滤,防止非 bot 用户成为所有者 - Added concurrency安全改进 (atomic.Bool for Stop) - 緻加单元测试覆盖并发场景 - 修复代码构建错误 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix R3: use SetOwners for Claim ownership - Fix R4: only set known bot IDs as owners - Add Stop() idempotent protection with atomic.Bool - Fix TTL test: use HasOwner - Add CleanupExpired test - Add UpdateLastActive test All tests pass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rygo#241) Key changes: - ThreadOwnershipTracker now tracks threads owned by THIS bot - Removed multi-owner tracking (OwnerIDs map) - Simplified API: Claim(), Release(), Owns() - Each bot instance independently tracks its owned threads - R3/R4: Multi-bot scenarios handled by independent bot instances - R5: Ownership release when others are mentioned Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
All Phase 1 MVP features implemented: - @mention detection and response - Thread reply mode - Owner policy (owner_only/trusted/public) - Bot-centric thread ownership tracking - Ownership transfer (R3) - Multi-owner support (independent tracking) - TTL expiration Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Resolve conflicts in socketmode.go: - Keep thread ownership decision logic - Remove duplicate bot mention check (upstream has it at line 218-221) - Preserve upstream improvements (event_type, event_ts metadata) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Owner
🔍 PR #242 综合审查报告审查完成,发现 4 个关键问题 和 6 个建议改进。 🔴 必须修复 (Critical)1. Nil Pointer Panic -
|
| # | 问题 | 文件 |
|---|---|---|
| 6 | Persist 字段定义但未使用 | config.go:54-57 |
| 7 | 缺少接口合规性验证 | thread_ownership.go |
| 8 | 缺少并发测试 | thread_ownership_test.go |
| 9 | events.go 和 socketmode.go 重复决策逻辑 | 多文件 |
| 10 | 建议添加 GetOwnedThreadCount() 方法 | thread_ownership.go |
✅ 正面观察
- 优秀的文档注释和设计规范 (
bot-behavior-spec.md) - 正确的 Mutex 使用模式
ThreadOwnershipTracker类型设计评分: 8.5/10- Bot-centric 所有权模型设计合理
📋 行动计划
合并前必须修复 (预估 15 分钟):
- 添加 nil check: socketmode.go:144
- 添加 Stop() 调用: adapter.go:252
审查结论:
added 2 commits
March 8, 2026 08:48
Critical fixes: - Add nil check for ownershipTracker in socketmode.go to prevent panic - Call ownershipTracker.Stop() in Adapter.Stop() to prevent goroutine leak - Return early from NewAdapter on config validation failure - Validate ThreadKey parameters to prevent empty key collisions - Change unknown OwnerPolicy default from public to owner_only (secure default)
…o#241) Fixes: - Add nil check for webhook.Stop() in Adapter.Stop() - Initialize webhook in NewAdapter failure path to prevent nil panic - Update ThreadKey validation to reject empty parameters - Add tests for empty ThreadKey cases - Fix test BotToken/SigningSecret format to match validation regex
hrygo
pushed a commit
that referenced
this pull request
Mar 16, 2026
* docs(design): add thread ownership policy design (Refs #241) * docs(design): update thread ownership with per-bot owned_set model (Refs #241) * docs(design): add slack thread creation flow analysis (Refs #241) * docs(design): add bot behavior specification with basic/advanced capabilities (Refs #241) * docs(design): add required channel behavior specification (Refs #241) * docs(design): finalize bot behavior spec v1.0 (Refs #241) - Add owner definition and policy configuration - Unify decision flow diagram - Add DM behavior and edge cases - Clean up duplicate content - Consolidate configuration structure * docs(design): remove obsolete thread-ownership-policy.md (Refs #241) * feat(slack): implement Phase 1 bot behavior spec (Refs #241) - Add Owner policy config (owner_only, trusted, public) - Add ThreadOwnershipTracker for thread ownership management - Implement unified decision flow for message response - Support multi-owner threads via @mention - Add TTL expiration for thread ownership - Integrate ownership logic in events.go and socketmode.go Phase 1 MVP features implemented: - @mention detection and response - Owner policy configuration - Thread ownership tracking - Ownership transfer on @mention - Multi-owner support - TTL expiration Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(slack): address code review issues for Phase 1 (Refs #241) - Implement R5: ownership release when other bots mentioned - Add background cleanup goroutine for expired ownerships - Add Stop() method for graceful shutdown - Fix ownership tracking with context-based lifecycle Issues addressed: - P0: R5 rule implementation (ownership release) - P1: Memory leak prevention (periodic cleanup) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(slack): address code review issues (Refs #241) - R3: @mention transfers ownership (was of bot mentions) - R4: Multi-bot mention creates shared ownership - R5: @mentions excluding current owner releases ownership - Added human用户过滤,防止非 bot 用户成为所有者 - Added concurrency安全改进 (atomic.Bool for Stop) - 緻加单元测试覆盖并发场景 - 修复代码构建错误 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(slack): finalize Phase 1 code review fixes (Refs #241) - Fix R3: use SetOwners for Claim ownership - Fix R4: only set known bot IDs as owners - Add Stop() idempotent protection with atomic.Bool - Fix TTL test: use HasOwner - Add CleanupExpired test - Add UpdateLastActive test All tests pass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor(slack): redesign thread ownership to bot-centric model (Refs #241) Key changes: - ThreadOwnershipTracker now tracks threads owned by THIS bot - Removed multi-owner tracking (OwnerIDs map) - Simplified API: Claim(), Release(), Owns() - Each bot instance independently tracks its owned threads - R3/R4: Multi-bot scenarios handled by independent bot instances - R5: Ownership release when others are mentioned Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs(design): mark Phase 1 implementation complete (Refs #241) All Phase 1 MVP features implemented: - @mention detection and response - Thread reply mode - Owner policy (owner_only/trusted/public) - Bot-centric thread ownership tracking - Ownership transfer (R3) - Multi-owner support (independent tracking) - TTL expiration Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(slack): address PR #242 review feedback (Refs #241) Critical fixes: - Add nil check for ownershipTracker in socketmode.go to prevent panic - Call ownershipTracker.Stop() in Adapter.Stop() to prevent goroutine leak - Return early from NewAdapter on config validation failure - Validate ThreadKey parameters to prevent empty key collisions - Change unknown OwnerPolicy default from public to owner_only (secure default) * fix(slack): address PR #242 review feedback - round 2 (Refs #241) Fixes: - Add nil check for webhook.Stop() in Adapter.Stop() - Initialize webhook in NewAdapter failure path to prevent nil panic - Update ThreadKey validation to reject empty parameters - Add tests for empty ThreadKey cases - Fix test BotToken/SigningSecret format to match validation regex --------- Co-authored-by: HotPlexBot01 <noreply@hotplex.dev> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
hrygo
pushed a commit
that referenced
this pull request
Mar 16, 2026
* docs(design): add thread ownership policy design (Refs #241) * docs(design): update thread ownership with per-bot owned_set model (Refs #241) * docs(design): add slack thread creation flow analysis (Refs #241) * docs(design): add bot behavior specification with basic/advanced capabilities (Refs #241) * docs(design): add required channel behavior specification (Refs #241) * docs(design): finalize bot behavior spec v1.0 (Refs #241) - Add owner definition and policy configuration - Unify decision flow diagram - Add DM behavior and edge cases - Clean up duplicate content - Consolidate configuration structure * docs(design): remove obsolete thread-ownership-policy.md (Refs #241) * feat(slack): implement Phase 1 bot behavior spec (Refs #241) - Add Owner policy config (owner_only, trusted, public) - Add ThreadOwnershipTracker for thread ownership management - Implement unified decision flow for message response - Support multi-owner threads via @mention - Add TTL expiration for thread ownership - Integrate ownership logic in events.go and socketmode.go Phase 1 MVP features implemented: - @mention detection and response - Owner policy configuration - Thread ownership tracking - Ownership transfer on @mention - Multi-owner support - TTL expiration Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(slack): address code review issues for Phase 1 (Refs #241) - Implement R5: ownership release when other bots mentioned - Add background cleanup goroutine for expired ownerships - Add Stop() method for graceful shutdown - Fix ownership tracking with context-based lifecycle Issues addressed: - P0: R5 rule implementation (ownership release) - P1: Memory leak prevention (periodic cleanup) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(slack): address code review issues (Refs #241) - R3: @mention transfers ownership (was of bot mentions) - R4: Multi-bot mention creates shared ownership - R5: @mentions excluding current owner releases ownership - Added human用户过滤,防止非 bot 用户成为所有者 - Added concurrency安全改进 (atomic.Bool for Stop) - 緻加单元测试覆盖并发场景 - 修复代码构建错误 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(slack): finalize Phase 1 code review fixes (Refs #241) - Fix R3: use SetOwners for Claim ownership - Fix R4: only set known bot IDs as owners - Add Stop() idempotent protection with atomic.Bool - Fix TTL test: use HasOwner - Add CleanupExpired test - Add UpdateLastActive test All tests pass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor(slack): redesign thread ownership to bot-centric model (Refs #241) Key changes: - ThreadOwnershipTracker now tracks threads owned by THIS bot - Removed multi-owner tracking (OwnerIDs map) - Simplified API: Claim(), Release(), Owns() - Each bot instance independently tracks its owned threads - R3/R4: Multi-bot scenarios handled by independent bot instances - R5: Ownership release when others are mentioned Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs(design): mark Phase 1 implementation complete (Refs #241) All Phase 1 MVP features implemented: - @mention detection and response - Thread reply mode - Owner policy (owner_only/trusted/public) - Bot-centric thread ownership tracking - Ownership transfer (R3) - Multi-owner support (independent tracking) - TTL expiration Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(slack): address PR #242 review feedback (Refs #241) Critical fixes: - Add nil check for ownershipTracker in socketmode.go to prevent panic - Call ownershipTracker.Stop() in Adapter.Stop() to prevent goroutine leak - Return early from NewAdapter on config validation failure - Validate ThreadKey parameters to prevent empty key collisions - Change unknown OwnerPolicy default from public to owner_only (secure default) * fix(slack): address PR #242 review feedback - round 2 (Refs #241) Fixes: - Add nil check for webhook.Stop() in Adapter.Stop() - Initialize webhook in NewAdapter failure path to prevent nil panic - Update ThreadKey validation to reject empty parameters - Add tests for empty ThreadKey cases - Fix test BotToken/SigningSecret format to match validation regex --------- Co-authored-by: HotPlexBot01 <noreply@hotplex.dev> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement Phase 1 of bot-behavior-spec.md for multi-bot Slack channel support. Add Owner Policy configuration (owner_only/trusted/public). Add bot-centric thread ownership tracking with TTL expiration. Implement R3/R4/R5 ownership rules. Resolves #241