refactor(slack): extract allow-list source behind AllowListSource trait#1152
Merged
thepagent merged 1 commit intoJun 19, 2026
Conversation
Introduces a small `AllowListSource` trait (src/allow_list.rs) that the Slack adapter consumes via `Arc<dyn AllowListSource>` instead of a bare `HashSet<String>`. The in-tree `StaticAllowList` default wraps a fixed set loaded once from `[slack].allowed_users`, preserving existing behaviour exactly. The seam lets downstream forks plug in alternative implementations (e.g. a file-watching impl that mirrors an IdP group) without modifying the gate-check call sites. Snapshot semantics (each dispatch captures `Arc<HashSet<String>>` via `.allowed_users()`) make hot-reload implementations lock-free on the read path. Scope is Slack-only; discord/gateway adapters continue to use their existing `HashSet<String>` parameters and may adopt the trait in follow-ups if their communities want it. Per Discord discussion on RFC openabdev#1109 — the original sync-feature direction in openabdev#1109 is superseded by this trait-only refactor; IdP-sync implementations live in downstream forks. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Collaborator
|
LGTM ✅ — Clean trait extraction with zero behaviour change; well-tested and narrowly scoped. What This PR DoesExtracts the Slack allow-list gate into a pluggable How It Works
Findings
What's Good (🟢)
Baseline Check
CI NoteThe failing |
thepagent
approved these changes
Jun 19, 2026
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.
Summary
AllowListSourcetrait (src/allow_list.rs)StaticAllowListwraps[slack].allowed_users— behaviour-preserving refactorsrc/slack.rs::run_slack_adaptertakesArc<dyn AllowListSource>instead of bareHashSet<String>.allowed_users()→Arc<HashSet<String>>, lock-free on the read pathContext
This PR supersedes #1109 (sync-feature for
[slack].allowed_usersin core). Per Discord discussion on 2026-06-16, the consensus is to keep openab core IdP-agnostic and provide a clean extension point so downstream forks can add IdP-aware sources themselves.@pahud-nodejs approved the trait-only refactor direction: 「完全合理,來吧!這很好!」
The actual IdP-sync implementation (e.g. Okta Groups → file → hot-reload) lives in downstream forks; openab core only commits to the trait shape.
File changes
src/allow_list.rs(new)StaticAllowListdefault + 3 unit tests (round-trip, snapshot Arc-sharing, hot-swap throughdyndispatch via a mock impl)src/main.rsmod allow_list;; wrap config-loaded HashSet inStaticAllowListbefore passing torun_slack_adaptersrc/slack.rsrun_slack_adapterparameter type change;use crate::allow_list::AllowListSource;; two spawn-site preambles resolve.allowed_users()to a snapshot before dispatchNet: ~14 lines changed in existing files + ~110 lines of new module (mostly tests). No behaviour change.
Scope
discordandgatewayadapters continue to take bareHashSet<String>and may adopt the trait in follow-ups if their communities want it.Test plan
cargo check— cleancargo test --bin openab allow_list— 3/3 passingcargo test --bin openab— 512 passing; one pre-existing failure (secrets::tests::resolve_exec_nonzero_exit) also fails on cleanupstream/main, unrelated to this PRcargo clippy --bin openab -- -D warnings— cleancargo fmt --check— formatting diff reported is on a pre-existing line (socket_idletest,src/slack.rs:~2332) that also reproduces on cleanupstream/main; not introduced hereOut of scope (follow-ups)
AllowListSource— lives in downstream forks[discord].allowed_users/[gateway].allowed_usersallowed_channels/trusted_bot_idsCloses #1109 (superseded by this trait-only direction)