medre-adapter-simplexchat 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 (60) hide show
  1. medre_adapter_simplexchat-0.1.0/LICENSE +21 -0
  2. medre_adapter_simplexchat-0.1.0/PKG-INFO +304 -0
  3. medre_adapter_simplexchat-0.1.0/README.md +285 -0
  4. medre_adapter_simplexchat-0.1.0/pyproject.toml +68 -0
  5. medre_adapter_simplexchat-0.1.0/setup.cfg +4 -0
  6. medre_adapter_simplexchat-0.1.0/src/medre/adapters/simplexchat/__init__.py +1 -0
  7. medre_adapter_simplexchat-0.1.0/src/medre/adapters/simplexchat/__main__.py +6 -0
  8. medre_adapter_simplexchat-0.1.0/src/medre/adapters/simplexchat/adapter.py +600 -0
  9. medre_adapter_simplexchat-0.1.0/src/medre/adapters/simplexchat/cli.py +313 -0
  10. medre_adapter_simplexchat-0.1.0/src/medre/adapters/simplexchat/cli_contrib.py +71 -0
  11. medre_adapter_simplexchat-0.1.0/src/medre/adapters/simplexchat/codec.py +248 -0
  12. medre_adapter_simplexchat-0.1.0/src/medre/adapters/simplexchat/compat.py +5 -0
  13. medre_adapter_simplexchat-0.1.0/src/medre/adapters/simplexchat/config.py +135 -0
  14. medre_adapter_simplexchat-0.1.0/src/medre/adapters/simplexchat/fake.py +117 -0
  15. medre_adapter_simplexchat-0.1.0/src/medre/adapters/simplexchat/metadata.py +53 -0
  16. medre_adapter_simplexchat-0.1.0/src/medre/adapters/simplexchat/plugin.py +58 -0
  17. medre_adapter_simplexchat-0.1.0/src/medre/adapters/simplexchat/py.typed +0 -0
  18. medre_adapter_simplexchat-0.1.0/src/medre/adapters/simplexchat/renderer.py +172 -0
  19. medre_adapter_simplexchat-0.1.0/src/medre/adapters/simplexchat/sample.py +8 -0
  20. medre_adapter_simplexchat-0.1.0/src/medre/adapters/simplexchat/session.py +305 -0
  21. medre_adapter_simplexchat-0.1.0/src/medre/adapters/simplexchat/setup_journey.py +151 -0
  22. medre_adapter_simplexchat-0.1.0/src/medre/adapters/simplexchat/state.py +245 -0
  23. medre_adapter_simplexchat-0.1.0/src/medre/adapters/simplexchat/stopped_declaration.py +137 -0
  24. medre_adapter_simplexchat-0.1.0/src/medre/adapters/simplexchat/worker.py +314 -0
  25. medre_adapter_simplexchat-0.1.0/src/medre_adapter_simplexchat.egg-info/PKG-INFO +304 -0
  26. medre_adapter_simplexchat-0.1.0/src/medre_adapter_simplexchat.egg-info/SOURCES.txt +58 -0
  27. medre_adapter_simplexchat-0.1.0/src/medre_adapter_simplexchat.egg-info/dependency_links.txt +1 -0
  28. medre_adapter_simplexchat-0.1.0/src/medre_adapter_simplexchat.egg-info/entry_points.txt +5 -0
  29. medre_adapter_simplexchat-0.1.0/src/medre_adapter_simplexchat.egg-info/requires.txt +9 -0
  30. medre_adapter_simplexchat-0.1.0/src/medre_adapter_simplexchat.egg-info/top_level.txt +1 -0
  31. medre_adapter_simplexchat-0.1.0/tests/test_cli.py +446 -0
  32. medre_adapter_simplexchat-0.1.0/tests/test_cli_contrib.py +92 -0
  33. medre_adapter_simplexchat-0.1.0/tests/test_common_diagnostics.py +50 -0
  34. medre_adapter_simplexchat-0.1.0/tests/test_config_codec_renderer.py +266 -0
  35. medre_adapter_simplexchat-0.1.0/tests/test_distribution_license.py +28 -0
  36. medre_adapter_simplexchat-0.1.0/tests/test_durable_runtime.py +353 -0
  37. medre_adapter_simplexchat-0.1.0/tests/test_event_buffer.py +65 -0
  38. medre_adapter_simplexchat-0.1.0/tests/test_link_creation_sdk.py +151 -0
  39. medre_adapter_simplexchat-0.1.0/tests/test_linux_parent_death_guard.py +170 -0
  40. medre_adapter_simplexchat-0.1.0/tests/test_native_health.py +168 -0
  41. medre_adapter_simplexchat-0.1.0/tests/test_native_metadata.py +348 -0
  42. medre_adapter_simplexchat-0.1.0/tests/test_native_peer_evidence_gate.py +179 -0
  43. medre_adapter_simplexchat-0.1.0/tests/test_native_quote_lookup.py +78 -0
  44. medre_adapter_simplexchat-0.1.0/tests/test_native_reply_promotion.py +86 -0
  45. medre_adapter_simplexchat-0.1.0/tests/test_native_reply_sdk.py +116 -0
  46. medre_adapter_simplexchat-0.1.0/tests/test_pin_literal_hygiene.py +124 -0
  47. medre_adapter_simplexchat-0.1.0/tests/test_plugin_api_version.py +11 -0
  48. medre_adapter_simplexchat-0.1.0/tests/test_project_tooling.py +78 -0
  49. medre_adapter_simplexchat-0.1.0/tests/test_quoted_handoff_ownership.py +129 -0
  50. medre_adapter_simplexchat-0.1.0/tests/test_recorded_native_quote_boundaries.py +555 -0
  51. medre_adapter_simplexchat-0.1.0/tests/test_recorded_native_quote_evidence.py +117 -0
  52. medre_adapter_simplexchat-0.1.0/tests/test_relay_prefix_surface.py +83 -0
  53. medre_adapter_simplexchat-0.1.0/tests/test_schemas.py +32 -0
  54. medre_adapter_simplexchat-0.1.0/tests/test_scoped_quote_rendering.py +65 -0
  55. medre_adapter_simplexchat-0.1.0/tests/test_sdk_contract.py +92 -0
  56. medre_adapter_simplexchat-0.1.0/tests/test_session.py +191 -0
  57. medre_adapter_simplexchat-0.1.0/tests/test_session_ownership.py +286 -0
  58. medre_adapter_simplexchat-0.1.0/tests/test_session_process_group_linux.py +166 -0
  59. medre_adapter_simplexchat-0.1.0/tests/test_setup_journey.py +221 -0
  60. medre_adapter_simplexchat-0.1.0/tests/test_stopped_declaration.py +215 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jeremiah K.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,304 @@
1
+ Metadata-Version: 2.4
2
+ Name: medre-adapter-simplexchat
3
+ Version: 0.1.0
4
+ Summary: SimpleX Chat groups for MEDRE through the official Python client
5
+ License-Expression: MIT
6
+ Classifier: Typing :: Typed
7
+ Requires-Python: >=3.11
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: medre<0.2.0,>=0.1.0
11
+ Requires-Dist: simplex-chat==7.1.3
12
+ Provides-Extra: test
13
+ Requires-Dist: pytest==9.2.0; extra == "test"
14
+ Requires-Dist: pytest-asyncio==1.5.0; extra == "test"
15
+ Requires-Dist: pytest-timeout==2.4.0; extra == "test"
16
+ Requires-Dist: pytest-cov==7.1.0; extra == "test"
17
+ Requires-Dist: jsonschema==4.26.0; extra == "test"
18
+ Dynamic: license-file
19
+
20
+ # MEDRE SimpleX Chat adapter
21
+
22
+ Bridge allowlisted SimpleX Chat groups and direct conversations through the
23
+ [official Python client](https://github.com/simplex-chat/simplex-chat/tree/stable/packages/simplex-chat-python).
24
+ Group chat is the primary workflow. The provider includes plain-text attribution,
25
+ scoped native replies with readable fallback, durable admission, and an SDK-free fake for development.
26
+
27
+ ## Install
28
+
29
+ Keep core and adapters in one locked uv project:
30
+
31
+ ```bash
32
+ uv init --bare medre-bridge
33
+ cd medre-bridge
34
+ uv add 'medre @ git+https://github.com/jeremiah-k/medre.git@main' \
35
+ 'medre-adapter-simplexchat @ git+https://github.com/jeremiah-k/medre-adapter-simplexchat.git@main'
36
+ ```
37
+
38
+ Use immutable Git revisions for reproducible deployments. The provider pins the
39
+ released official `simplex-chat` package at the manifest pin. Its native library is downloaded
40
+ on first initialization; no separate CLI daemon or unofficial wrapper is needed.
41
+ The SDK supports Linux, macOS and Windows on its published architectures; CI
42
+ qualifies Linux x86-64. The new private-link export commands require POSIX
43
+ file permissions; they reject non-POSIX platforms before native mutation.
44
+ This restriction does not change the other commands. This adapter's code is MIT licensed. The official SDK and
45
+ native library carry their own AGPL-3.0 license.
46
+
47
+ For a persistent MEDRE tool installation, `medre adapters install simplexchat`
48
+ adds the provider to the same environment. Use `medre adapter simplexchat` for
49
+ profile commands. The standalone `medre-simplexchat` entry point remains
50
+ available in activated project environments with the same arguments.
51
+
52
+ ## Setup guidance boundary
53
+
54
+ > The commands in this journey use `--adapter sx` as an **example** instance.
55
+ > Replace that value consistently with the actual configured provider ID before
56
+ > running commands. `medre config native` displays instructions only; it does
57
+ > not substitute IDs, provision accounts, or create a bridge.
58
+
59
+ `medre config native` offers no SimpleX form and never provisions this
60
+ transport. What it prints depends on the installed core revision:
61
+
62
+ - Cores without a typed setup-guidance seam refuse the transport with
63
+ "'simplexchat' has no provider-declared native setup prompts; use its
64
+ native configuration guide", pointing at this provider-owned guide.
65
+ - Cores with the seam render the provider's declared setup journey as an
66
+ informational, offline listing of the same commands with per-step evidence
67
+ notes, classified `informational_only`. The render exits without writing a
68
+ configuration file, invokes nothing, and claims no provisioning: it is
69
+ guidance, not setup.
70
+
71
+ Both behaviors route to the same journey below and to
72
+ `medre adapter simplexchat` for actual profile provisioning; core does not
73
+ invoke those commands automatically because they contact the native service,
74
+ unlike `config native`.
75
+
76
+ Core's `AdapterSpec` carries provider-owned setup surfaces: `cli_register`,
77
+ which exposes the provider's provisioning commands in the journey below;
78
+ `native_setup_fields`, an offline form that prompts for provider-declared
79
+ config values and writes a new YAML without contacting an SDK, account, or
80
+ device; and, on cores with the typed seam, `native_setup_instructions`, the
81
+ informational journey for form-less providers that this provider declares.
82
+ SimpleX profile, contact, and group provisioning cannot happen offline:
83
+ connection links and group membership require the native service. An offline
84
+ form could reference an existing profile, but could not provision it or
85
+ complete contact and group membership. The provider declares no such form;
86
+ it declares its journey as typed instructions so `medre config native` can
87
+ print exactly the commands below with evidence notes at their true levels. A
88
+ linked contact or a created group is not independently witnessed delivery,
89
+ and provisioning results are never relay acceptance, delivery, or read
90
+ evidence; they grant no send authority. This document remains the
91
+ configuration guide that older cores' refusal points to.
92
+
93
+ ## Provision a dedicated profile
94
+
95
+ Setup proceeds in stages: prerequisites, explicit provisioning commands,
96
+ verification, and the configuration reference. Provisioning always contacts the
97
+ native service; initialization is explicit and starting MEDRE does not silently
98
+ create a SimpleX identity.
99
+
100
+ ### Stage 1: prerequisites
101
+
102
+ - Stop MEDRE before profile commands. MEDRE commands exclusively lock the
103
+ profile; unrelated SimpleX clients do not honor this lock and must not open
104
+ it concurrently. The profile is dedicated to one MEDRE adapter and one
105
+ active native user.
106
+ - Pick one `--adapter` ID (the examples use `sx`) and, when overriding storage,
107
+ one `--database-prefix`. Use the same selection for setup and runtime.
108
+ Profiles default to MEDRE's private instance state directory under
109
+ `adapters/sx/simplexchat/profile`; `MEDRE_HOME` and XDG paths are honored.
110
+ - The pinned official `simplex-chat` SDK downloads its native library
111
+ on first initialization; `libs_dir` selects an existing official native
112
+ library directory instead.
113
+
114
+ ### Stage 2: explicit provisioning commands
115
+
116
+ Run the provider's own commands in order. In a uv deployment project, prefix
117
+ each with `uv run --locked`; the standalone `medre-simplexchat` entry point
118
+ takes the same arguments.
119
+
120
+ ```bash
121
+ medre adapter simplexchat init --adapter sx --name 'MEDRE bridge'
122
+ medre adapter simplexchat join --adapter sx
123
+ medre adapter simplexchat groups --adapter sx --json
124
+ ```
125
+
126
+ `init` creates the private bot profile and its active native user. `join`
127
+ prompts for a private contact or group connection link without echoing it;
128
+ use `--link-stdin` for automation. A requested connection is persisted, and
129
+ the command keeps native networking active for up to `--wait-seconds` (60 by
130
+ default). The remote peer may need to approve.
131
+
132
+ The profile can also originate connections. `create-address --adapter sx --out PATH`
133
+ creates or retains the profile's contact address and sets auto-accept using the
134
+ bot's normal profile (not a business address). This does not reject incognito
135
+ remote peers. `create-link --adapter sx --group-id ID --out PATH` creates or
136
+ exports the existing member-role invitation for a local group reported by
137
+ `groups`. Existing links with another role are refused, not changed. The
138
+ `address_created` and `group_link_created` result fields indicate whether a new
139
+ native link was created, not whether export succeeded on a prior invocation.
140
+
141
+ Both export commands require POSIX owner-only file permissions. Use an
142
+ operator-controlled output directory on a filesystem that enforces them.
143
+ The command writes a fresh `0600` file and atomically replaces the destination
144
+ entry, including a symlink entry without following its target. It does not
145
+ modify an existing inode, even if it has other hard links or open readers.
146
+ Link material is never printed. If export fails after native creation,
147
+ correct `--out` and repeat the same command against the same profile and group;
148
+ the existing link is retained. An interrupted process may leave an owner-only
149
+ temporary file in the output directory. Treat it as private too.
150
+ Peers complete the connection while `connect --adapter sx` keeps native
151
+ networking active. Group-link joins may complete without a separate approval
152
+ step. Configure and verify native admission policy separately if approval is
153
+ required; these commands do not enforce it.
154
+
155
+ Provisioning completes with explicit actions. `accept-group --adapter sx --group-id ID`
156
+ accepts an invited group, `connect --adapter sx` resumes pending native
157
+ connections for a bounded interval, and
158
+ `create-group --adapter sx --name 'Bridge room'` creates a bot-owned group.
159
+ `contacts --adapter sx` lists direct chat IDs from the same profile.
160
+
161
+ ### Stage 3: verification
162
+
163
+ Read each result at its true evidence level:
164
+
165
+ - `groups` and `contacts` print the profile's native listings. A connection
166
+ observation does not establish group membership; the command output itself
167
+ states that a connected contact does not prove group membership. Accept an
168
+ invited group with `accept-group --adapter sx --group-id ID` before routing
169
+ it, and use `connect --adapter sx` again when a request stays pending.
170
+ - Group/member/contact IDs are local to this dedicated profile; they are not
171
+ global SimpleX identities.
172
+ - `create-address` and `create-link` prove local native state only. The written
173
+ link is the capability to connect, so keep its owner-only file private.
174
+ Inspect native membership and admission policy independently; a group-link
175
+ join may be accepted automatically. Creating or exporting a link is not
176
+ relay acceptance, delivery, or read evidence.
177
+ - A linked contact is not an independently witnessed delivery. Nothing above
178
+ proves a peer received a message: outbound acceptance confirms only the
179
+ native local queue, and health describes the local native session, not peer
180
+ reachability. See [Delivery and recovery](#delivery-and-recovery).
181
+
182
+ ### Stage 4: configuration reference
183
+
184
+ Use IDs from this profile's `groups` or `contacts` output:
185
+
186
+ ```yaml
187
+ adapters:
188
+ simplexchat:
189
+ sx:
190
+ user_id: 1
191
+ chats: [group:7, contact:3]
192
+ origin_label: SimpleX Chat
193
+ ```
194
+
195
+ When a runtime YAML exists, `--config bridge.yaml --adapter sx` selects its
196
+ profile and honors MEDRE's environment overrides. Routes use explicit channel
197
+ strings such as `source_channel: "group:7"` and `dest_channel: "group:7"`.
198
+ Both source and destination channels must be allowlisted. Ordinary active
199
+ groups and accepted active contacts are supported; private group support
200
+ conversations are excluded. This example configures only one provider;
201
+ add a second adapter and explicit route legs with `medre config bridge`.
202
+ Run `medre config check` and `medre routes plan` before starting; these
203
+ offline checks do not prove native acceptance or recipient delivery.
204
+
205
+ Set an encrypted profile's key with `MEDRE_ADAPTER__SX__DATABASE_KEY`; keep it
206
+ out of YAML and arguments. `database_prefix` and `state_dir` override private
207
+ storage. On Linux, `native_cache_dir` controls the SDK cache through XDG; on
208
+ other systems the SDK uses its platform cache. `libs_dir` selects an existing
209
+ official native library directory on any supported platform.
210
+
211
+ ## Delivery and recovery
212
+
213
+ Text is rendered with MEDRE's relay attribution. When the official client
214
+ supplies a peer's profile, the peer-declared display name (then full name)
215
+ leads the attribution prefix; the local word-pair alias and the scoped sender
216
+ identity remain the fallbacks, and missing or non-printable names degrade
217
+ without invention. The codec also captures the SDK's native facts in the
218
+ versioned namespace: the shared stable member ID (an additional identifier
219
+ alongside the scoped sender identity) and role for group members,
220
+ per-item signature-verification verdicts, and mention/link flags. The explicit
221
+ `public_facts` allowlist (`msg_verified`, `member_role`) crosses into another
222
+ transport's relay context; the rest of the namespace stays out of the `off`,
223
+ `minimal`, and `safe` metadata export modes, but an operator-selected explicit
224
+ `full` metadata export embeds the whole namespace and can disclose the member
225
+ ID. Replies use destination-bound native quotes when the retained parent is
226
+ verified in the active profile and conversation. Missing, deleted or mismatched
227
+ parents retain readable fallback. Threads remain fallback; attachments, edits,
228
+ deletions, reactions, typing, and puppeting are not advertised. Received control items, sent echoes, blocked members, file
229
+ captions, live partial messages, and private support chats are excluded.
230
+
231
+ The first successful scan establishes a baseline without replaying existing
232
+ history. Restart recovery walks every retained history page using native
233
+ pagination and a local ledger of processed IDs. Group history is timestamp
234
+ ordered: late messages can have higher IDs and earlier positions. Recovery
235
+ admits missing items in oldest-page-first order without assuming increasing
236
+ IDs. Each baseline page commits its IDs in one transaction. Recovery must not
237
+ stop at a fully retained page: older pages can still contain unseen, backdated
238
+ messages. Startup cost and retained ID storage grow with native history; for
239
+ large profiles, allow additional startup time and monitor profile growth.
240
+
241
+ Live events use a native buffer bounded to 256 items and 1 MiB. Overflow stops the adapter;
242
+ restart recovery reads retained messages from the native profile. Admission
243
+ refusals retain the pending event for retry. Stable canonical IDs let core
244
+ deduplicate an admission repeated across a crash. Native history deleted or expired
245
+ before recovery cannot be reconstructed. Back up the profile, ownership sidecar,
246
+ MEDRE state, and adapter ledgers together; do not reuse these ledgers for a reset
247
+ native profile.
248
+
249
+ Outbound acceptance confirms only the native **local queue**, not remote delivery.
250
+ An exact confirmed attempt can return its stored native reference without sending
251
+ again. A conflicting attempt, uncertain native outcome, or different attempt for
252
+ the same outbox requires inspection of the native profile; the adapter refuses a
253
+ blind resubmission. If the session rejects a send _before any command is
254
+ written_, the unsent reservation is released and core can retry. A native
255
+ rejection after submission is not proof of no handoff and remains uncertain.
256
+ Health describes the local native session, not peer reachability.
257
+
258
+ ## Develop and validate
259
+
260
+ Register arbitrary checkout paths with `medre dev`; sibling directories are not
261
+ required:
262
+
263
+ ```bash
264
+ medre dev sync --project /path/to/medre --sources /path/to/dev-sources.yaml \
265
+ --editable simplexchat=/path/to/medre-adapter-simplexchat simplexchat
266
+ ```
267
+
268
+ The explicit source catalog can contain:
269
+
270
+ ```yaml
271
+ adapters:
272
+ simplexchat: medre-adapter-simplexchat @ git+https://github.com/jeremiah-k/medre-adapter-simplexchat.git@main
273
+ ```
274
+
275
+ Add `--sdk` to install the native dependency. See `medre dev --help` for workspace
276
+ selection and dependency options. CI checks
277
+ this adapter against core `main`, resolved once per run, recording both revisions.
278
+ Keep `MEDRE_CORE_REF` unset. Its manual `core_ref`
279
+ input qualifies a candidate core revision without committing temporary branch pins.
280
+
281
+ Run tests from a development environment containing core and this provider:
282
+
283
+ ```bash
284
+ python -m pytest -q
285
+ python -m simplex_chat install
286
+ python -m pytest -q -m "simplexchat_sdk and not local_integration and not soak and not live and not hardware and not docker"
287
+ ```
288
+
289
+ The default suite uses deterministic SDK boundaries and real subprocess ownership
290
+ tests. The opt-in SDK tier creates a disposable native profile and self-owned group
291
+ and proves local queue acceptance. It does not prove remote message receipt.
292
+ Independent-profile group routing and adding SimpleX to the native all-adapter
293
+ campaign require a separate live qualification run.
294
+
295
+ The [provider contract](docs/spec/simplexchat.md) and
296
+ [configuration schema](docs/schemas/config.schema.json) describe the runtime
297
+ boundaries and versioned metadata projection.
298
+
299
+ ## Development tooling
300
+
301
+ See [contributing](CONTRIBUTING.md) for the shared Trunk quality gate and uv-based
302
+ editable development workflow.
303
+
304
+ Native reply qualification is recorded in the [boundary follow-up](docs/evidence/native-reply-boundaries-sdk-7.1.3-2026-11-16/README.md).
@@ -0,0 +1,285 @@
1
+ # MEDRE SimpleX Chat adapter
2
+
3
+ Bridge allowlisted SimpleX Chat groups and direct conversations through the
4
+ [official Python client](https://github.com/simplex-chat/simplex-chat/tree/stable/packages/simplex-chat-python).
5
+ Group chat is the primary workflow. The provider includes plain-text attribution,
6
+ scoped native replies with readable fallback, durable admission, and an SDK-free fake for development.
7
+
8
+ ## Install
9
+
10
+ Keep core and adapters in one locked uv project:
11
+
12
+ ```bash
13
+ uv init --bare medre-bridge
14
+ cd medre-bridge
15
+ uv add 'medre @ git+https://github.com/jeremiah-k/medre.git@main' \
16
+ 'medre-adapter-simplexchat @ git+https://github.com/jeremiah-k/medre-adapter-simplexchat.git@main'
17
+ ```
18
+
19
+ Use immutable Git revisions for reproducible deployments. The provider pins the
20
+ released official `simplex-chat` package at the manifest pin. Its native library is downloaded
21
+ on first initialization; no separate CLI daemon or unofficial wrapper is needed.
22
+ The SDK supports Linux, macOS and Windows on its published architectures; CI
23
+ qualifies Linux x86-64. The new private-link export commands require POSIX
24
+ file permissions; they reject non-POSIX platforms before native mutation.
25
+ This restriction does not change the other commands. This adapter's code is MIT licensed. The official SDK and
26
+ native library carry their own AGPL-3.0 license.
27
+
28
+ For a persistent MEDRE tool installation, `medre adapters install simplexchat`
29
+ adds the provider to the same environment. Use `medre adapter simplexchat` for
30
+ profile commands. The standalone `medre-simplexchat` entry point remains
31
+ available in activated project environments with the same arguments.
32
+
33
+ ## Setup guidance boundary
34
+
35
+ > The commands in this journey use `--adapter sx` as an **example** instance.
36
+ > Replace that value consistently with the actual configured provider ID before
37
+ > running commands. `medre config native` displays instructions only; it does
38
+ > not substitute IDs, provision accounts, or create a bridge.
39
+
40
+ `medre config native` offers no SimpleX form and never provisions this
41
+ transport. What it prints depends on the installed core revision:
42
+
43
+ - Cores without a typed setup-guidance seam refuse the transport with
44
+ "'simplexchat' has no provider-declared native setup prompts; use its
45
+ native configuration guide", pointing at this provider-owned guide.
46
+ - Cores with the seam render the provider's declared setup journey as an
47
+ informational, offline listing of the same commands with per-step evidence
48
+ notes, classified `informational_only`. The render exits without writing a
49
+ configuration file, invokes nothing, and claims no provisioning: it is
50
+ guidance, not setup.
51
+
52
+ Both behaviors route to the same journey below and to
53
+ `medre adapter simplexchat` for actual profile provisioning; core does not
54
+ invoke those commands automatically because they contact the native service,
55
+ unlike `config native`.
56
+
57
+ Core's `AdapterSpec` carries provider-owned setup surfaces: `cli_register`,
58
+ which exposes the provider's provisioning commands in the journey below;
59
+ `native_setup_fields`, an offline form that prompts for provider-declared
60
+ config values and writes a new YAML without contacting an SDK, account, or
61
+ device; and, on cores with the typed seam, `native_setup_instructions`, the
62
+ informational journey for form-less providers that this provider declares.
63
+ SimpleX profile, contact, and group provisioning cannot happen offline:
64
+ connection links and group membership require the native service. An offline
65
+ form could reference an existing profile, but could not provision it or
66
+ complete contact and group membership. The provider declares no such form;
67
+ it declares its journey as typed instructions so `medre config native` can
68
+ print exactly the commands below with evidence notes at their true levels. A
69
+ linked contact or a created group is not independently witnessed delivery,
70
+ and provisioning results are never relay acceptance, delivery, or read
71
+ evidence; they grant no send authority. This document remains the
72
+ configuration guide that older cores' refusal points to.
73
+
74
+ ## Provision a dedicated profile
75
+
76
+ Setup proceeds in stages: prerequisites, explicit provisioning commands,
77
+ verification, and the configuration reference. Provisioning always contacts the
78
+ native service; initialization is explicit and starting MEDRE does not silently
79
+ create a SimpleX identity.
80
+
81
+ ### Stage 1: prerequisites
82
+
83
+ - Stop MEDRE before profile commands. MEDRE commands exclusively lock the
84
+ profile; unrelated SimpleX clients do not honor this lock and must not open
85
+ it concurrently. The profile is dedicated to one MEDRE adapter and one
86
+ active native user.
87
+ - Pick one `--adapter` ID (the examples use `sx`) and, when overriding storage,
88
+ one `--database-prefix`. Use the same selection for setup and runtime.
89
+ Profiles default to MEDRE's private instance state directory under
90
+ `adapters/sx/simplexchat/profile`; `MEDRE_HOME` and XDG paths are honored.
91
+ - The pinned official `simplex-chat` SDK downloads its native library
92
+ on first initialization; `libs_dir` selects an existing official native
93
+ library directory instead.
94
+
95
+ ### Stage 2: explicit provisioning commands
96
+
97
+ Run the provider's own commands in order. In a uv deployment project, prefix
98
+ each with `uv run --locked`; the standalone `medre-simplexchat` entry point
99
+ takes the same arguments.
100
+
101
+ ```bash
102
+ medre adapter simplexchat init --adapter sx --name 'MEDRE bridge'
103
+ medre adapter simplexchat join --adapter sx
104
+ medre adapter simplexchat groups --adapter sx --json
105
+ ```
106
+
107
+ `init` creates the private bot profile and its active native user. `join`
108
+ prompts for a private contact or group connection link without echoing it;
109
+ use `--link-stdin` for automation. A requested connection is persisted, and
110
+ the command keeps native networking active for up to `--wait-seconds` (60 by
111
+ default). The remote peer may need to approve.
112
+
113
+ The profile can also originate connections. `create-address --adapter sx --out PATH`
114
+ creates or retains the profile's contact address and sets auto-accept using the
115
+ bot's normal profile (not a business address). This does not reject incognito
116
+ remote peers. `create-link --adapter sx --group-id ID --out PATH` creates or
117
+ exports the existing member-role invitation for a local group reported by
118
+ `groups`. Existing links with another role are refused, not changed. The
119
+ `address_created` and `group_link_created` result fields indicate whether a new
120
+ native link was created, not whether export succeeded on a prior invocation.
121
+
122
+ Both export commands require POSIX owner-only file permissions. Use an
123
+ operator-controlled output directory on a filesystem that enforces them.
124
+ The command writes a fresh `0600` file and atomically replaces the destination
125
+ entry, including a symlink entry without following its target. It does not
126
+ modify an existing inode, even if it has other hard links or open readers.
127
+ Link material is never printed. If export fails after native creation,
128
+ correct `--out` and repeat the same command against the same profile and group;
129
+ the existing link is retained. An interrupted process may leave an owner-only
130
+ temporary file in the output directory. Treat it as private too.
131
+ Peers complete the connection while `connect --adapter sx` keeps native
132
+ networking active. Group-link joins may complete without a separate approval
133
+ step. Configure and verify native admission policy separately if approval is
134
+ required; these commands do not enforce it.
135
+
136
+ Provisioning completes with explicit actions. `accept-group --adapter sx --group-id ID`
137
+ accepts an invited group, `connect --adapter sx` resumes pending native
138
+ connections for a bounded interval, and
139
+ `create-group --adapter sx --name 'Bridge room'` creates a bot-owned group.
140
+ `contacts --adapter sx` lists direct chat IDs from the same profile.
141
+
142
+ ### Stage 3: verification
143
+
144
+ Read each result at its true evidence level:
145
+
146
+ - `groups` and `contacts` print the profile's native listings. A connection
147
+ observation does not establish group membership; the command output itself
148
+ states that a connected contact does not prove group membership. Accept an
149
+ invited group with `accept-group --adapter sx --group-id ID` before routing
150
+ it, and use `connect --adapter sx` again when a request stays pending.
151
+ - Group/member/contact IDs are local to this dedicated profile; they are not
152
+ global SimpleX identities.
153
+ - `create-address` and `create-link` prove local native state only. The written
154
+ link is the capability to connect, so keep its owner-only file private.
155
+ Inspect native membership and admission policy independently; a group-link
156
+ join may be accepted automatically. Creating or exporting a link is not
157
+ relay acceptance, delivery, or read evidence.
158
+ - A linked contact is not an independently witnessed delivery. Nothing above
159
+ proves a peer received a message: outbound acceptance confirms only the
160
+ native local queue, and health describes the local native session, not peer
161
+ reachability. See [Delivery and recovery](#delivery-and-recovery).
162
+
163
+ ### Stage 4: configuration reference
164
+
165
+ Use IDs from this profile's `groups` or `contacts` output:
166
+
167
+ ```yaml
168
+ adapters:
169
+ simplexchat:
170
+ sx:
171
+ user_id: 1
172
+ chats: [group:7, contact:3]
173
+ origin_label: SimpleX Chat
174
+ ```
175
+
176
+ When a runtime YAML exists, `--config bridge.yaml --adapter sx` selects its
177
+ profile and honors MEDRE's environment overrides. Routes use explicit channel
178
+ strings such as `source_channel: "group:7"` and `dest_channel: "group:7"`.
179
+ Both source and destination channels must be allowlisted. Ordinary active
180
+ groups and accepted active contacts are supported; private group support
181
+ conversations are excluded. This example configures only one provider;
182
+ add a second adapter and explicit route legs with `medre config bridge`.
183
+ Run `medre config check` and `medre routes plan` before starting; these
184
+ offline checks do not prove native acceptance or recipient delivery.
185
+
186
+ Set an encrypted profile's key with `MEDRE_ADAPTER__SX__DATABASE_KEY`; keep it
187
+ out of YAML and arguments. `database_prefix` and `state_dir` override private
188
+ storage. On Linux, `native_cache_dir` controls the SDK cache through XDG; on
189
+ other systems the SDK uses its platform cache. `libs_dir` selects an existing
190
+ official native library directory on any supported platform.
191
+
192
+ ## Delivery and recovery
193
+
194
+ Text is rendered with MEDRE's relay attribution. When the official client
195
+ supplies a peer's profile, the peer-declared display name (then full name)
196
+ leads the attribution prefix; the local word-pair alias and the scoped sender
197
+ identity remain the fallbacks, and missing or non-printable names degrade
198
+ without invention. The codec also captures the SDK's native facts in the
199
+ versioned namespace: the shared stable member ID (an additional identifier
200
+ alongside the scoped sender identity) and role for group members,
201
+ per-item signature-verification verdicts, and mention/link flags. The explicit
202
+ `public_facts` allowlist (`msg_verified`, `member_role`) crosses into another
203
+ transport's relay context; the rest of the namespace stays out of the `off`,
204
+ `minimal`, and `safe` metadata export modes, but an operator-selected explicit
205
+ `full` metadata export embeds the whole namespace and can disclose the member
206
+ ID. Replies use destination-bound native quotes when the retained parent is
207
+ verified in the active profile and conversation. Missing, deleted or mismatched
208
+ parents retain readable fallback. Threads remain fallback; attachments, edits,
209
+ deletions, reactions, typing, and puppeting are not advertised. Received control items, sent echoes, blocked members, file
210
+ captions, live partial messages, and private support chats are excluded.
211
+
212
+ The first successful scan establishes a baseline without replaying existing
213
+ history. Restart recovery walks every retained history page using native
214
+ pagination and a local ledger of processed IDs. Group history is timestamp
215
+ ordered: late messages can have higher IDs and earlier positions. Recovery
216
+ admits missing items in oldest-page-first order without assuming increasing
217
+ IDs. Each baseline page commits its IDs in one transaction. Recovery must not
218
+ stop at a fully retained page: older pages can still contain unseen, backdated
219
+ messages. Startup cost and retained ID storage grow with native history; for
220
+ large profiles, allow additional startup time and monitor profile growth.
221
+
222
+ Live events use a native buffer bounded to 256 items and 1 MiB. Overflow stops the adapter;
223
+ restart recovery reads retained messages from the native profile. Admission
224
+ refusals retain the pending event for retry. Stable canonical IDs let core
225
+ deduplicate an admission repeated across a crash. Native history deleted or expired
226
+ before recovery cannot be reconstructed. Back up the profile, ownership sidecar,
227
+ MEDRE state, and adapter ledgers together; do not reuse these ledgers for a reset
228
+ native profile.
229
+
230
+ Outbound acceptance confirms only the native **local queue**, not remote delivery.
231
+ An exact confirmed attempt can return its stored native reference without sending
232
+ again. A conflicting attempt, uncertain native outcome, or different attempt for
233
+ the same outbox requires inspection of the native profile; the adapter refuses a
234
+ blind resubmission. If the session rejects a send _before any command is
235
+ written_, the unsent reservation is released and core can retry. A native
236
+ rejection after submission is not proof of no handoff and remains uncertain.
237
+ Health describes the local native session, not peer reachability.
238
+
239
+ ## Develop and validate
240
+
241
+ Register arbitrary checkout paths with `medre dev`; sibling directories are not
242
+ required:
243
+
244
+ ```bash
245
+ medre dev sync --project /path/to/medre --sources /path/to/dev-sources.yaml \
246
+ --editable simplexchat=/path/to/medre-adapter-simplexchat simplexchat
247
+ ```
248
+
249
+ The explicit source catalog can contain:
250
+
251
+ ```yaml
252
+ adapters:
253
+ simplexchat: medre-adapter-simplexchat @ git+https://github.com/jeremiah-k/medre-adapter-simplexchat.git@main
254
+ ```
255
+
256
+ Add `--sdk` to install the native dependency. See `medre dev --help` for workspace
257
+ selection and dependency options. CI checks
258
+ this adapter against core `main`, resolved once per run, recording both revisions.
259
+ Keep `MEDRE_CORE_REF` unset. Its manual `core_ref`
260
+ input qualifies a candidate core revision without committing temporary branch pins.
261
+
262
+ Run tests from a development environment containing core and this provider:
263
+
264
+ ```bash
265
+ python -m pytest -q
266
+ python -m simplex_chat install
267
+ python -m pytest -q -m "simplexchat_sdk and not local_integration and not soak and not live and not hardware and not docker"
268
+ ```
269
+
270
+ The default suite uses deterministic SDK boundaries and real subprocess ownership
271
+ tests. The opt-in SDK tier creates a disposable native profile and self-owned group
272
+ and proves local queue acceptance. It does not prove remote message receipt.
273
+ Independent-profile group routing and adding SimpleX to the native all-adapter
274
+ campaign require a separate live qualification run.
275
+
276
+ The [provider contract](docs/spec/simplexchat.md) and
277
+ [configuration schema](docs/schemas/config.schema.json) describe the runtime
278
+ boundaries and versioned metadata projection.
279
+
280
+ ## Development tooling
281
+
282
+ See [contributing](CONTRIBUTING.md) for the shared Trunk quality gate and uv-based
283
+ editable development workflow.
284
+
285
+ Native reply qualification is recorded in the [boundary follow-up](docs/evidence/native-reply-boundaries-sdk-7.1.3-2026-11-16/README.md).
@@ -0,0 +1,68 @@
1
+ [project]
2
+ name = "medre-adapter-simplexchat"
3
+ version = "0.1.0"
4
+ description = "SimpleX Chat groups for MEDRE through the official Python client"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ license = "MIT"
8
+ classifiers = ["Typing :: Typed"]
9
+ dependencies = ["medre>=0.1.0,<0.2.0", "simplex-chat==7.1.3"]
10
+
11
+ [project.scripts]
12
+ medre-simplexchat = "medre.adapters.simplexchat.cli:main"
13
+
14
+ [project.entry-points."medre.adapters"]
15
+ simplexchat = "medre.adapters.simplexchat.plugin:adapter_spec"
16
+
17
+ [project.optional-dependencies]
18
+ test = [
19
+ "pytest==9.2.0",
20
+ "pytest-asyncio==1.5.0",
21
+ "pytest-timeout==2.4.0",
22
+ "pytest-cov==7.1.0",
23
+ "jsonschema==4.26.0",
24
+ ]
25
+
26
+ [build-system]
27
+ requires = ["setuptools>=77"]
28
+ build-backend = "setuptools.build_meta"
29
+
30
+ [tool.setuptools.packages.find]
31
+ where = ["src"]
32
+
33
+ [tool.setuptools.package-data]
34
+ "medre.adapters.simplexchat" = ["py.typed"]
35
+
36
+ [tool.pytest.ini_options]
37
+ asyncio_mode = "auto"
38
+ asyncio_default_fixture_loop_scope = "function"
39
+ testpaths = ["tests"]
40
+ pythonpath = ["src"]
41
+ filterwarnings = ["error"]
42
+ timeout = 30
43
+ addopts = "-m 'not simplexchat_sdk and not live'"
44
+ markers = [
45
+ "simplexchat_sdk: contracts against the released official native client",
46
+ "live: opt-in message delivery between dedicated SimpleX profiles",
47
+ ]
48
+
49
+ [tool.ruff]
50
+ line-length = 88
51
+ [tool.ruff.lint]
52
+ select = ["F", "E4", "E7", "E9", "B", "ASYNC", "RUF100"]
53
+ ignore = ["ASYNC109"]
54
+ [tool.black]
55
+ target-version = ["py311"]
56
+
57
+ [tool.mypy]
58
+ python_version = "3.11"
59
+ strict = true
60
+ explicit_package_bases = true
61
+ follow_imports = "silent"
62
+
63
+ [[tool.mypy.overrides]]
64
+ module = ["simplex_chat", "simplex_chat.*"]
65
+ ignore_missing_imports = true
66
+
67
+ [tool.isort]
68
+ profile = "black"