delegate-connector-slack 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. delegate_connector_slack-0.1.0/.env.example +16 -0
  2. delegate_connector_slack-0.1.0/.gitignore +74 -0
  3. delegate_connector_slack-0.1.0/LICENSE +201 -0
  4. delegate_connector_slack-0.1.0/PKG-INFO +153 -0
  5. delegate_connector_slack-0.1.0/README.md +123 -0
  6. delegate_connector_slack-0.1.0/docker-compose.yml +17 -0
  7. delegate_connector_slack-0.1.0/pyproject.toml +75 -0
  8. delegate_connector_slack-0.1.0/src/delegate_connectors/slack/__init__.py +38 -0
  9. delegate_connector_slack-0.1.0/src/delegate_connectors/slack/compose.py +246 -0
  10. delegate_connector_slack-0.1.0/src/delegate_connectors/slack/connector.py +509 -0
  11. delegate_connector_slack-0.1.0/src/delegate_connectors/slack/directory.py +146 -0
  12. delegate_connector_slack-0.1.0/src/delegate_connectors/slack/messages.py +155 -0
  13. delegate_connector_slack-0.1.0/src/delegate_connectors/slack/web_api.py +313 -0
  14. delegate_connector_slack-0.1.0/tests/conformance/conftest.py +15 -0
  15. delegate_connector_slack-0.1.0/tests/conformance/loader.py +111 -0
  16. delegate_connector_slack-0.1.0/tests/conformance/test_canonical_set.py +234 -0
  17. delegate_connector_slack-0.1.0/tests/conformance/vector_driver.py +447 -0
  18. delegate_connector_slack-0.1.0/tests/conftest.py +17 -0
  19. delegate_connector_slack-0.1.0/tests/integration/_live_slack.py +65 -0
  20. delegate_connector_slack-0.1.0/tests/integration/_slack_api_double.py +225 -0
  21. delegate_connector_slack-0.1.0/tests/integration/conftest.py +148 -0
  22. delegate_connector_slack-0.1.0/tests/integration/test_e2e.py +170 -0
  23. delegate_connector_slack-0.1.0/tests/integration/test_postmessage_roundtrip.py +141 -0
  24. delegate_connector_slack-0.1.0/tests/regression/__init__.py +21 -0
  25. delegate_connector_slack-0.1.0/tests/regression/conftest.py +149 -0
  26. delegate_connector_slack-0.1.0/tests/regression/test_invoke_authenticates.py +75 -0
  27. delegate_connector_slack-0.1.0/tests/regression/test_outbound_validation.py +95 -0
  28. delegate_connector_slack-0.1.0/tests/regression/test_receipt_identity_binding.py +172 -0
  29. delegate_connector_slack-0.1.0/tests/unit/test_compose.py +117 -0
  30. delegate_connector_slack-0.1.0/tests/unit/test_connector.py +426 -0
  31. delegate_connector_slack-0.1.0/tests/unit/test_directory.py +160 -0
  32. delegate_connector_slack-0.1.0/tests/unit/test_messages.py +170 -0
  33. delegate_connector_slack-0.1.0/tests/unit/test_web_api.py +239 -0
@@ -0,0 +1,16 @@
1
+ # Copyright 2026 Terrene Foundation
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ #
4
+ # Slack connector configuration. Copy to .env and fill in real values.
5
+ # NEVER commit a populated .env (root .gitignore excludes .env).
6
+ # All credentials are read from the environment — never hardcoded.
7
+
8
+ # --- Slack Web API (chat.postMessage + conversations.history) ---
9
+ # Bot token issued for the Slack app (format: xoxb-...). One token covers both
10
+ # the outbound send and the inbound bounded history pull.
11
+ SLACK_BOT_TOKEN=
12
+
13
+ # Optional: override the Slack Web API base URL. Leave empty to use the real
14
+ # Slack API (https://slack.com/api/). Set to the local mock-server URL for
15
+ # Tier-2 tests (e.g. http://localhost:8080/api/).
16
+ SLACK_API_BASE_URL=
@@ -0,0 +1,74 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ !.claude/hooks/lib/
15
+ lib64/
16
+ parts/
17
+ sdist/
18
+ var/
19
+ wheels/
20
+ *.egg-info/
21
+ .installed.cfg
22
+ *.egg
23
+ MANIFEST
24
+
25
+ # Virtual environments
26
+ .env
27
+ .venv
28
+ env/
29
+ venv/
30
+ ENV/
31
+ env.bak/
32
+ venv.bak/
33
+ .python-version
34
+
35
+ # IDE specific files
36
+ .idea/
37
+ .vscode/
38
+ *.swp
39
+ *.swo
40
+ .DS_Store
41
+ .jbeval/
42
+ output.txt
43
+
44
+ # Testing
45
+ .coverage
46
+ htmlcov/
47
+ .pytest_cache/
48
+ .mypy_cache/
49
+
50
+ # Secrets
51
+ *.pem
52
+ *.key
53
+ secrets/
54
+
55
+ # Workspace session notes (per-session, not versioned)
56
+ **/.session-notes
57
+
58
+ # Per-project learning data (generated at runtime)
59
+ .claude/learning/
60
+ .claude/rules/learned-instincts.md
61
+
62
+ # Runtime telemetry logs (generated by hooks at runtime)
63
+ .claude/logs/
64
+
65
+ # Internal docs (not for distribution)
66
+ /docs/01-kailash-vibe-cc-internals/
67
+
68
+ # Generated script outputs (sdk-users examples)
69
+ **/scripts/data/
70
+ **/scripts/outputs/
71
+ **/scripts/*.log
72
+
73
+ # Journal-hook runtime bookkeeping (per-clone skip log; not source)
74
+ **/.journal-skipped.log
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Support. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or support.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Terrene Foundation
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,153 @@
1
+ Metadata-Version: 2.4
2
+ Name: delegate-connector-slack
3
+ Version: 0.1.0
4
+ Summary: OSS Slack connector for the Terrene Delegate substrate (kailash.delegate).
5
+ Project-URL: Homepage, https://github.com/terrene-foundation/delegate-connectors
6
+ Project-URL: Changelog, https://github.com/terrene-foundation/delegate-connectors/blob/main/CHANGELOG.md
7
+ Author: Terrene Foundation
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Keywords: chat,connector,delegate,kailash,messaging,slack
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Communications :: Chat
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Requires-Python: >=3.10
21
+ Requires-Dist: aiohttp>=3.7.3
22
+ Requires-Dist: cryptography>=42.0
23
+ Requires-Dist: kailash>=2.28.0
24
+ Requires-Dist: slack-sdk>=3.27.0
25
+ Provides-Extra: test
26
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'test'
27
+ Requires-Dist: pytest>=8.0; extra == 'test'
28
+ Requires-Dist: python-dotenv>=1.0; extra == 'test'
29
+ Description-Content-Type: text/markdown
30
+
31
+ <!--
32
+ Copyright 2026 Terrene Foundation
33
+ SPDX-License-Identifier: Apache-2.0
34
+ -->
35
+
36
+ # delegate-connector-slack
37
+
38
+ An OSS Python connector for the Terrene Delegate substrate. Implements the
39
+ shipped `kailash.delegate.Connector` ABC (kailash 2.26.2) for Slack — the same
40
+ contract the email + WhatsApp connectors implement, with a Slack Web API
41
+ transport:
42
+
43
+ - **`write`** — `chat.postMessage` outbound send via the Slack Web API
44
+ (`AsyncWebClient`), executed under audit, returns a real
45
+ `SignedActionEnvelope`.
46
+ - **`read`** — a bounded `conversations.history` pull (one page per call),
47
+ executed under audit, returns `(messages, AttestedReadReceipt)`. The audited
48
+ manifest carries the channel + message `ts` ids + count only — never message
49
+ body bytes.
50
+ - **`authenticate`** — resolves a dispatch identity's `delegate_id` to a
51
+ `Principal` against a `SlackPrincipalResolver` (exact-match in v0; an unknown
52
+ identity resolves to `Reject`, fail-closed).
53
+ - **`invoke`** — single-method dispatch entry (used by the dispatch hot path);
54
+ authenticates FIRST (so an unknown sender's `Reject` fires before any Slack
55
+ API call), then posts via the audited `write` path and returns a
56
+ `ConnectorInvocationResult`.
57
+ - Trust properties — `auth_verifier` returns the supplied real
58
+ `Ed25519Verifier`; `ledger` returns an in-memory `InMemoryKnowledgeLedger`;
59
+ `revocation` returns a never-revoked `NeverRevokedChannel` (both
60
+ Protocol-satisfying deterministic concretes; framework-first, no custom trust
61
+ primitives).
62
+
63
+ It subclasses `Connector` **directly** (ADR-1) — NOT `LegacyInvokeConnector`,
64
+ whose proxied `read`/`write` emit empty, unverifiable receipts. This connector's
65
+ `read`/`write` produce non-empty receipts that verify under a real
66
+ `Ed25519Verifier`. It has no Rust-sibling dependency — it is a pure-Python
67
+ connector.
68
+
69
+ ## Inbound is a bounded `conversations.history` pull
70
+
71
+ Inbound messages are read via a bounded `conversations.history` pull, NOT Socket
72
+ Mode (ADR-S1). A persistent Socket Mode connection conflicts with the connector's
73
+ one-shot `read` thunk contract (one bounded fetch per audited read receipt), so
74
+ the connector pulls a single page per `read` call rather than holding an
75
+ event-streaming socket open.
76
+
77
+ ## Injection boundary
78
+
79
+ User-controlled message text is mrkdwn-escaped (`&`/`<`/`>`) and every id-bound
80
+ field is shape-validated at the `OutboundSlackMessage` construction boundary
81
+ (ADR-S3), so an injected `<@U…>` mention, `<!channel>` broadcast, or
82
+ `<url|label>` link cannot render live. Every outbound send route builds an
83
+ `OutboundSlackMessage` first, so the boundary covers all of them. Block Kit /
84
+ `attachments` / `blocks` are out of v0 scope — scoping them out removes the
85
+ structural-injection vector entirely (ADR-S3).
86
+
87
+ ## Install
88
+
89
+ ```bash
90
+ pip install -e connectors/slack
91
+ ```
92
+
93
+ ## Configure
94
+
95
+ All credentials come from the environment (see `.env.example`):
96
+ `SLACK_BOT_TOKEN` is the `xoxb-…` bot token (required; one bot-token credential
97
+ family covers both directions). `SLACK_API_BASE_URL` optionally overrides the
98
+ Web API base URL — used to point the client at the local in-process test server.
99
+ Nothing is hardcoded; nothing is logged.
100
+
101
+ ## Test
102
+
103
+ Tier-1 (unit, no I/O, no Slack Web API client required):
104
+
105
+ ```bash
106
+ pip install -e "connectors/slack[test]"
107
+ python -m pytest connectors/slack/tests/unit -q
108
+ ```
109
+
110
+ Tier-2/3 (real infra — an in-process protocol-faithful Slack Web API server over
111
+ a real socket; no mocks at the boundary):
112
+
113
+ ```bash
114
+ python -m pytest connectors/slack/tests/integration -q
115
+ ```
116
+
117
+ Because `slack_sdk`'s `AsyncWebClient` is aiohttp-based, the Tier-2 surrogate is
118
+ a **real in-process aiohttp server bound to an ephemeral port** (ADR-S4) — the
119
+ connector's real `AsyncWebClient` is pointed at it via `SLACK_API_BASE_URL`. This
120
+ is a Protocol-satisfying deterministic adapter over a real socket, not a mock at
121
+ the connector boundary, so the integration tests RUN (they do not skip). The
122
+ opt-in Tier-3 live-Slack test skips with a clear "cannot execute" reason unless
123
+ `SLACK_LIVE_E2E=1` plus real `SLACK_BOT_TOKEN` + `SLACK_LIVE_E2E_CHANNEL` are set
124
+ (it never falls back to a mock).
125
+
126
+ Conformance (canonical vector well-formedness + connector composition):
127
+
128
+ ```bash
129
+ python -m pytest connectors/slack/tests/conformance -q
130
+ ```
131
+
132
+ Regression (behavioral security guards — receipt identity binding,
133
+ authenticate-first fail-closed gate, outbound construction-boundary validation):
134
+
135
+ ```bash
136
+ python -m pytest connectors/slack/tests/regression -q
137
+ ```
138
+
139
+ ## Known limitation — runtime `execute()` audit gate
140
+
141
+ `compose.py` builds a real `DelegateRuntime` around the connector. However the
142
+ shipped `kailash.delegate` runtime/dispatch audit-emit path signs the event
143
+ payload bytes while `AuditChainEngine.emit_event` verifies the signature against
144
+ the full audit-entry signing bytes — so `runtime.execute()` fails at the first
145
+ audit emission under any real verifier (kailash-py#1182). This is an SDK bug in
146
+ `kailash.delegate`, not in this connector; the connector's own `read`/`write`
147
+ receipts verify correctly. The end-to-end `runtime.execute()` assertion is gated
148
+ on the SDK fix (a strict xfail in the conformance + e2e suites); the
149
+ connector-level post → history round-trip and receipt verification are not.
150
+
151
+ ## License
152
+
153
+ Apache 2.0. All open-source IP is owned by the Terrene Foundation.
@@ -0,0 +1,123 @@
1
+ <!--
2
+ Copyright 2026 Terrene Foundation
3
+ SPDX-License-Identifier: Apache-2.0
4
+ -->
5
+
6
+ # delegate-connector-slack
7
+
8
+ An OSS Python connector for the Terrene Delegate substrate. Implements the
9
+ shipped `kailash.delegate.Connector` ABC (kailash 2.26.2) for Slack — the same
10
+ contract the email + WhatsApp connectors implement, with a Slack Web API
11
+ transport:
12
+
13
+ - **`write`** — `chat.postMessage` outbound send via the Slack Web API
14
+ (`AsyncWebClient`), executed under audit, returns a real
15
+ `SignedActionEnvelope`.
16
+ - **`read`** — a bounded `conversations.history` pull (one page per call),
17
+ executed under audit, returns `(messages, AttestedReadReceipt)`. The audited
18
+ manifest carries the channel + message `ts` ids + count only — never message
19
+ body bytes.
20
+ - **`authenticate`** — resolves a dispatch identity's `delegate_id` to a
21
+ `Principal` against a `SlackPrincipalResolver` (exact-match in v0; an unknown
22
+ identity resolves to `Reject`, fail-closed).
23
+ - **`invoke`** — single-method dispatch entry (used by the dispatch hot path);
24
+ authenticates FIRST (so an unknown sender's `Reject` fires before any Slack
25
+ API call), then posts via the audited `write` path and returns a
26
+ `ConnectorInvocationResult`.
27
+ - Trust properties — `auth_verifier` returns the supplied real
28
+ `Ed25519Verifier`; `ledger` returns an in-memory `InMemoryKnowledgeLedger`;
29
+ `revocation` returns a never-revoked `NeverRevokedChannel` (both
30
+ Protocol-satisfying deterministic concretes; framework-first, no custom trust
31
+ primitives).
32
+
33
+ It subclasses `Connector` **directly** (ADR-1) — NOT `LegacyInvokeConnector`,
34
+ whose proxied `read`/`write` emit empty, unverifiable receipts. This connector's
35
+ `read`/`write` produce non-empty receipts that verify under a real
36
+ `Ed25519Verifier`. It has no Rust-sibling dependency — it is a pure-Python
37
+ connector.
38
+
39
+ ## Inbound is a bounded `conversations.history` pull
40
+
41
+ Inbound messages are read via a bounded `conversations.history` pull, NOT Socket
42
+ Mode (ADR-S1). A persistent Socket Mode connection conflicts with the connector's
43
+ one-shot `read` thunk contract (one bounded fetch per audited read receipt), so
44
+ the connector pulls a single page per `read` call rather than holding an
45
+ event-streaming socket open.
46
+
47
+ ## Injection boundary
48
+
49
+ User-controlled message text is mrkdwn-escaped (`&`/`<`/`>`) and every id-bound
50
+ field is shape-validated at the `OutboundSlackMessage` construction boundary
51
+ (ADR-S3), so an injected `<@U…>` mention, `<!channel>` broadcast, or
52
+ `<url|label>` link cannot render live. Every outbound send route builds an
53
+ `OutboundSlackMessage` first, so the boundary covers all of them. Block Kit /
54
+ `attachments` / `blocks` are out of v0 scope — scoping them out removes the
55
+ structural-injection vector entirely (ADR-S3).
56
+
57
+ ## Install
58
+
59
+ ```bash
60
+ pip install -e connectors/slack
61
+ ```
62
+
63
+ ## Configure
64
+
65
+ All credentials come from the environment (see `.env.example`):
66
+ `SLACK_BOT_TOKEN` is the `xoxb-…` bot token (required; one bot-token credential
67
+ family covers both directions). `SLACK_API_BASE_URL` optionally overrides the
68
+ Web API base URL — used to point the client at the local in-process test server.
69
+ Nothing is hardcoded; nothing is logged.
70
+
71
+ ## Test
72
+
73
+ Tier-1 (unit, no I/O, no Slack Web API client required):
74
+
75
+ ```bash
76
+ pip install -e "connectors/slack[test]"
77
+ python -m pytest connectors/slack/tests/unit -q
78
+ ```
79
+
80
+ Tier-2/3 (real infra — an in-process protocol-faithful Slack Web API server over
81
+ a real socket; no mocks at the boundary):
82
+
83
+ ```bash
84
+ python -m pytest connectors/slack/tests/integration -q
85
+ ```
86
+
87
+ Because `slack_sdk`'s `AsyncWebClient` is aiohttp-based, the Tier-2 surrogate is
88
+ a **real in-process aiohttp server bound to an ephemeral port** (ADR-S4) — the
89
+ connector's real `AsyncWebClient` is pointed at it via `SLACK_API_BASE_URL`. This
90
+ is a Protocol-satisfying deterministic adapter over a real socket, not a mock at
91
+ the connector boundary, so the integration tests RUN (they do not skip). The
92
+ opt-in Tier-3 live-Slack test skips with a clear "cannot execute" reason unless
93
+ `SLACK_LIVE_E2E=1` plus real `SLACK_BOT_TOKEN` + `SLACK_LIVE_E2E_CHANNEL` are set
94
+ (it never falls back to a mock).
95
+
96
+ Conformance (canonical vector well-formedness + connector composition):
97
+
98
+ ```bash
99
+ python -m pytest connectors/slack/tests/conformance -q
100
+ ```
101
+
102
+ Regression (behavioral security guards — receipt identity binding,
103
+ authenticate-first fail-closed gate, outbound construction-boundary validation):
104
+
105
+ ```bash
106
+ python -m pytest connectors/slack/tests/regression -q
107
+ ```
108
+
109
+ ## Known limitation — runtime `execute()` audit gate
110
+
111
+ `compose.py` builds a real `DelegateRuntime` around the connector. However the
112
+ shipped `kailash.delegate` runtime/dispatch audit-emit path signs the event
113
+ payload bytes while `AuditChainEngine.emit_event` verifies the signature against
114
+ the full audit-entry signing bytes — so `runtime.execute()` fails at the first
115
+ audit emission under any real verifier (kailash-py#1182). This is an SDK bug in
116
+ `kailash.delegate`, not in this connector; the connector's own `read`/`write`
117
+ receipts verify correctly. The end-to-end `runtime.execute()` assertion is gated
118
+ on the SDK fix (a strict xfail in the conformance + e2e suites); the
119
+ connector-level post → history round-trip and receipt verification are not.
120
+
121
+ ## License
122
+
123
+ Apache 2.0. All open-source IP is owned by the Terrene Foundation.
@@ -0,0 +1,17 @@
1
+ # Copyright 2026 Terrene Foundation
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ #
4
+ # Tier-2 test infrastructure for the Slack connector.
5
+ #
6
+ # Slack is a hosted SaaS with NO self-hostable real server, so the email
7
+ # connector's "real mail container" model cannot be copied literally. Instead a
8
+ # single Web API mock-server container serves the two methods v0 uses
9
+ # (chat.postMessage record+return-ts, conversations.history replay), talked to by
10
+ # a real AsyncWebClient(base_url=...). The SERVER is the local stub, exactly as
11
+ # Mailpit is a local SMTP server — there is NO mocking at the connector boundary
12
+ # (ADR-S4, workspaces/slack/journal/0003-GAP-*).
13
+ #
14
+ # The concrete service entry (image + seeded response shapes + ports) is filled
15
+ # in by the Tier-2 test shard. This scaffold reserves the file so the layout
16
+ # matches the email connector.
17
+ services: {}
@@ -0,0 +1,75 @@
1
+ # Copyright 2026 Terrene Foundation
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ [build-system]
4
+ requires = ["hatchling"]
5
+ build-backend = "hatchling.build"
6
+
7
+ [project]
8
+ name = "delegate-connector-slack"
9
+ dynamic = ["version"]
10
+ description = "OSS Slack connector for the Terrene Delegate substrate (kailash.delegate)."
11
+ readme = "README.md"
12
+ requires-python = ">=3.10"
13
+ license = "Apache-2.0"
14
+ license-files = ["LICENSE"]
15
+ authors = [{ name = "Terrene Foundation" }]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Intended Audience :: Developers",
19
+ "Operating System :: OS Independent",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Topic :: Communications :: Chat",
25
+ "Topic :: Software Development :: Libraries :: Python Modules",
26
+ ]
27
+ keywords = ["kailash", "delegate", "connector", "slack", "chat", "messaging"]
28
+ dependencies = [
29
+ # Connector ABC (write/read/authenticate) + Principal/SignedActionEnvelope
30
+ # landed in kailash 2.26.1; 2.24.0-2.25.2 ImportError on Principal. Floor 2.28.0:
31
+ # kailash-py#1182 (runtime audit-emit signature bug) fixed at <=2.28.1; dev/CI pin 2.28.1.
32
+ "kailash>=2.28.0",
33
+ # Slack Web API client (AsyncWebClient) for chat.postMessage +
34
+ # conversations.history. NOT required by the Wave-1 pure-logic modules
35
+ # (messages.py / directory.py) but declared because the connector + transport
36
+ # (later shards) compose AsyncWebClient directly.
37
+ "slack_sdk>=3.27.0",
38
+ # slack_sdk's AsyncWebClient (the real chat.postMessage / conversations.history
39
+ # transport) requires aiohttp, which slack_sdk only pulls via its [optional]
40
+ # extra — declared explicitly here because the connector composes AsyncWebClient
41
+ # on the production path AND the Tier-2 in-process double imports aiohttp.web
42
+ # directly (declared = imported).
43
+ "aiohttp>=3.7.3",
44
+ # Ed25519Verifier requires the cryptography lib (kailash [trust] extra ships
45
+ # it; declared here because this connector composes a real Ed25519Verifier
46
+ # directly, mirroring the email connector).
47
+ "cryptography>=42.0",
48
+ ]
49
+
50
+ [project.optional-dependencies]
51
+ test = [
52
+ "pytest>=8.0",
53
+ "pytest-asyncio>=0.23",
54
+ "python-dotenv>=1.0",
55
+ ]
56
+
57
+ [project.urls]
58
+ Homepage = "https://github.com/terrene-foundation/delegate-connectors"
59
+ Changelog = "https://github.com/terrene-foundation/delegate-connectors/blob/main/CHANGELOG.md"
60
+
61
+ [tool.hatch.version]
62
+ path = "src/delegate_connectors/slack/__init__.py"
63
+
64
+ [tool.hatch.build.targets.wheel]
65
+ packages = ["src/delegate_connectors"]
66
+
67
+ [tool.pytest.ini_options]
68
+ asyncio_mode = "auto"
69
+ asyncio_default_fixture_loop_scope = "function"
70
+ testpaths = ["tests"]
71
+ markers = [
72
+ "integration: real-infra Tier-2/3 tests (require a running Slack Web API mock-server container)",
73
+ "regression: regression tests guarding a specific fixed bug (NEVER deleted)",
74
+ "conformance: canonical conformance vector tests",
75
+ ]