convilyn-edge 0.1.0b3__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 (50) hide show
  1. convilyn_edge-0.1.0b3/.gitignore +18 -0
  2. convilyn_edge-0.1.0b3/CHANGELOG.md +111 -0
  3. convilyn_edge-0.1.0b3/LICENSE +201 -0
  4. convilyn_edge-0.1.0b3/PKG-INFO +194 -0
  5. convilyn_edge-0.1.0b3/README.md +164 -0
  6. convilyn_edge-0.1.0b3/examples/README.md +47 -0
  7. convilyn_edge-0.1.0b3/pyproject.toml +115 -0
  8. convilyn_edge-0.1.0b3/src/convilyn_edge/__init__.py +132 -0
  9. convilyn_edge-0.1.0b3/src/convilyn_edge/_version.py +15 -0
  10. convilyn_edge-0.1.0b3/src/convilyn_edge/cli/__init__.py +7 -0
  11. convilyn_edge-0.1.0b3/src/convilyn_edge/cli/main.py +97 -0
  12. convilyn_edge-0.1.0b3/src/convilyn_edge/cli/scaffold.py +137 -0
  13. convilyn_edge-0.1.0b3/src/convilyn_edge/clientcompute/__init__.py +74 -0
  14. convilyn_edge-0.1.0b3/src/convilyn_edge/clientcompute/bridge.py +184 -0
  15. convilyn_edge-0.1.0b3/src/convilyn_edge/clientcompute/contract.py +226 -0
  16. convilyn_edge-0.1.0b3/src/convilyn_edge/clientcompute/engine.py +239 -0
  17. convilyn_edge-0.1.0b3/src/convilyn_edge/clientcompute/operator.py +130 -0
  18. convilyn_edge-0.1.0b3/src/convilyn_edge/envelope.py +205 -0
  19. convilyn_edge-0.1.0b3/src/convilyn_edge/offline/__init__.py +40 -0
  20. convilyn_edge-0.1.0b3/src/convilyn_edge/offline/emitter.py +122 -0
  21. convilyn_edge-0.1.0b3/src/convilyn_edge/offline/idempotency.py +60 -0
  22. convilyn_edge-0.1.0b3/src/convilyn_edge/offline/queue.py +168 -0
  23. convilyn_edge-0.1.0b3/src/convilyn_edge/probe.py +239 -0
  24. convilyn_edge-0.1.0b3/src/convilyn_edge/py.typed +0 -0
  25. convilyn_edge-0.1.0b3/src/convilyn_edge/result.py +118 -0
  26. convilyn_edge-0.1.0b3/src/convilyn_edge/simulator.py +133 -0
  27. convilyn_edge-0.1.0b3/src/convilyn_edge/spi/__init__.py +92 -0
  28. convilyn_edge-0.1.0b3/src/convilyn_edge/spi/action.py +120 -0
  29. convilyn_edge-0.1.0b3/src/convilyn_edge/spi/model.py +112 -0
  30. convilyn_edge-0.1.0b3/src/convilyn_edge/spi/normalizer.py +54 -0
  31. convilyn_edge-0.1.0b3/src/convilyn_edge/spi/operator.py +71 -0
  32. convilyn_edge-0.1.0b3/src/convilyn_edge/spi/review.py +80 -0
  33. convilyn_edge-0.1.0b3/src/convilyn_edge/spi/source.py +78 -0
  34. convilyn_edge-0.1.0b3/src/convilyn_edge/spi/state.py +48 -0
  35. convilyn_edge-0.1.0b3/tests/__init__.py +0 -0
  36. convilyn_edge-0.1.0b3/tests/test_cli.py +139 -0
  37. convilyn_edge-0.1.0b3/tests/test_clientcompute_bridge.py +141 -0
  38. convilyn_edge-0.1.0b3/tests/test_clientcompute_contract.py +202 -0
  39. convilyn_edge-0.1.0b3/tests/test_clientcompute_engine.py +187 -0
  40. convilyn_edge-0.1.0b3/tests/test_clientcompute_operator.py +132 -0
  41. convilyn_edge-0.1.0b3/tests/test_envelope.py +181 -0
  42. convilyn_edge-0.1.0b3/tests/test_litmus_anti_divergence.py +133 -0
  43. convilyn_edge-0.1.0b3/tests/test_offline_emitter.py +189 -0
  44. convilyn_edge-0.1.0b3/tests/test_offline_idempotency.py +67 -0
  45. convilyn_edge-0.1.0b3/tests/test_offline_queue.py +171 -0
  46. convilyn_edge-0.1.0b3/tests/test_packaging.py +53 -0
  47. convilyn_edge-0.1.0b3/tests/test_probe.py +212 -0
  48. convilyn_edge-0.1.0b3/tests/test_result.py +130 -0
  49. convilyn_edge-0.1.0b3/tests/test_simulator.py +223 -0
  50. convilyn_edge-0.1.0b3/tests/test_spi_protocols.py +156 -0
@@ -0,0 +1,18 @@
1
+ # Build / packaging
2
+ /dist/
3
+ /build/
4
+ *.egg-info/
5
+
6
+ # Virtual envs
7
+ .venv/
8
+ venv/
9
+
10
+ # Test / coverage artifacts
11
+ .pytest_cache/
12
+ .coverage
13
+ coverage.xml
14
+ htmlcov/
15
+
16
+ # Byte-compiled
17
+ __pycache__/
18
+ *.py[cod]
@@ -0,0 +1,111 @@
1
+ # Changelog
2
+
3
+ All notable changes to `convilyn-edge` are documented here. The SDK's public
4
+ surface follows Semantic Versioning; pre-1.0 minor/patch may still adjust
5
+ surface under the alpha label.
6
+
7
+ ## 0.1.0b3 — unreleased (PR4: device simulator + CLI)
8
+
9
+ Drive a workflow with no hardware, and scaffold new adapters/workflows.
10
+
11
+ ### Added
12
+
13
+ - **`convilyn_edge.simulator`** — `SimulatedSource`, the first concrete
14
+ `EventSource` implementation: replay a JSON `Scenario` (device + ordered
15
+ events, with per-event `delay_ms` / `repeat`) as an `EventEnvelope` stream. The
16
+ moat-safe simulator half of the SDK; zero dependencies.
17
+ - **The `convilyn-edge` CLI** (stdlib `argparse`, zero deps):
18
+ - `simulate <scenario.json> [--no-delay]` — replay a scenario, printing each
19
+ envelope as a wire-JSON line (the v0.1 device-plane dev-run; `--no-delay`
20
+ gives a deterministic replay).
21
+ - `init adapter|workflow <name> [--path DIR]` — scaffold a conventional
22
+ adapter / workflow skeleton (reference §十四).
23
+
24
+ ### Changed
25
+
26
+ - Retired the POC `ainalyn_edge_runner` sample-input generators
27
+ (`make_samples.py`, `make_demo_jds.py`) — superseded by the `convilyn-edge`
28
+ simulator + scaffolds.
29
+
30
+ ### Deferred to v0.2
31
+
32
+ - `dev run` / `trace replay` — they need the workflow executor + a trace-export
33
+ format that are out of v0.1 scope. `simulate --no-delay` is the deterministic
34
+ replay subset for now.
35
+
36
+ ## 0.1.0b2 — unreleased (PR3: offline queue + Event Envelope emitter)
37
+
38
+ Offline-first buffering: the device keeps working when the cloud is unreachable,
39
+ and flushes exactly once when it returns.
40
+
41
+ ### Added
42
+
43
+ - **`convilyn_edge.offline`** — zero runtime dependencies:
44
+ - `DurableQueue` — a JSONL-backed, **idempotent** FIFO queue: a record whose
45
+ apply-once key is already queued is dropped, so a re-queue never duplicates a
46
+ pending item. `pending` / `enqueue` / `clear` / `replace` (atomic rewrite).
47
+ - `derive_idempotency_key` — the content-addressed apply-once key, a byte-exact
48
+ mirror of the server reconcile contract (device clock excluded), so the
49
+ server re-derives the same key and a re-flush is a no-op.
50
+ - `EventEmitter` + `EventSink` — emit an `EventEnvelope` to an injected sink;
51
+ when the sink is offline the envelope is buffered durably (keyed by its unique
52
+ `event_id`) instead of dropped, and `flush()` drains the buffer apply-once.
53
+ Reuses the `traceparent`-style correlation convention; the transport is
54
+ injected, so the package takes on no HTTP/MQTT dependency.
55
+
56
+ ### Changed
57
+
58
+ - The POC `ainalyn_edge_runner` offline capture queue (`queue.jsonl`) now uses the
59
+ productized `DurableQueue` (idempotent enqueue; same file, same replay UX).
60
+
61
+ ## 0.1.0b1 — unreleased (PR2: client_compute keystone)
62
+
63
+ The on-device extractor keystone — `convilyn-edge` now **confirms-and-consumes**
64
+ the frozen `client_compute` interrupt contract v1, so a cloud workflow can
65
+ delegate the extractor role to the device and the device answers with grounded
66
+ anchors (the server re-grounds before trusting them).
67
+
68
+ ### Added
69
+
70
+ - **`convilyn_edge.clientcompute`** — the client-compute round-trip, zero runtime
71
+ dependencies:
72
+ - `contract` — parse the frozen v1 interrupt payload (`ClientComputeRequest`,
73
+ `AnchorsContract`), `build_resume_answer`, and `ground_anchors` — the device
74
+ self-verify that mirrors the server's substring re-grounding (verbatim
75
+ substring or the `"Not specified"` sentinel; per-value + total caps enforced).
76
+ - `engine` — `LocalExtractor` Protocol + `HttpLocalExtractor` (Ollama and
77
+ OpenAI-compatible wires over stdlib `urllib`; transport injectable for tests).
78
+ - `operator` — `EdgeModelOperator`, an `edge`-placement `ModelOperator` that
79
+ runs the local model + grounds and returns a typed `ModelResult`.
80
+ - `bridge` — `ClientComputeBridge`, which drives one interrupt to resume via
81
+ narrow injected Protocols (`GoalClientPort`, `FileTextResolver`) — the
82
+ consumer SDK is injected, never imported (the core stays dependency-free).
83
+
84
+ ### Changed
85
+
86
+ - Retired the POC `docs/research/poc/ainalyn_edge_runner/local_llm.py` (its
87
+ extract + self-verify logic is absorbed here); the POC runner now consumes the
88
+ productized package.
89
+
90
+ ## 0.1.0b0 — unreleased (PR1: SPI scaffold)
91
+
92
+ Initial scaffold of the Edge AI Workflow SDK — the SPI only, zero runtime
93
+ dependencies.
94
+
95
+ ### Added
96
+
97
+ - **Event Envelope** (`convilyn_edge.envelope`): `EventEnvelope`,
98
+ `EventSourceRef`, `Correlation`, and the `new_envelope(...)` factory, with
99
+ `to_wire()` / `from_wire()` camelCase serialization. Reference-architecture §四.
100
+ - **`Result[T, E]`** (`convilyn_edge.result`): an `Ok` / `Err` tagged union for
101
+ exception-free, statically-narrowable fallible outcomes.
102
+ - **The 7-primitive SPI** (`convilyn_edge.spi`): `EventSource`, `Normalizer`,
103
+ `StateProvider`, `DeterministicOperator`, `ModelOperator`, `HumanReview`,
104
+ `ActionSink` — typed Protocols + their frozen dataclasses. Reference §三.
105
+ - Package scaffold: `src/` layout, `py.typed`, dynamic version, `dependencies = []`.
106
+
107
+ ### Notes
108
+
109
+ - No implementations ship in PR1 — Protocols + data shapes only. The
110
+ `client_compute` `ModelOperator` (PR2), offline queue + emitter (PR3),
111
+ simulator + CLI (PR4), and the removable retail Solution Pack (PR5) follow.
@@ -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 Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may accept (and charge a
167
+ fee for) acceptance of support, warranty, indemnity, or other
168
+ liability obligations and/or rights consistent with this License.
169
+ However, in accepting such obligations, You may act only on Your
170
+ own behalf and on Your sole responsibility, not on behalf of any
171
+ other Contributor, and only if You agree to indemnify, defend,
172
+ and hold each Contributor harmless for any liability incurred by,
173
+ or claims asserted against, such Contributor by reason of your
174
+ accepting any such warranty or additional liability.
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 CoreNovus contributors
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
200
+ implied. See the License for the specific language governing
201
+ permissions and limitations under the License.
@@ -0,0 +1,194 @@
1
+ Metadata-Version: 2.4
2
+ Name: convilyn-edge
3
+ Version: 0.1.0b3
4
+ Summary: Convilyn Edge AI Workflow SDK — the 7-primitive Device Data Plane SPI for building auditable, offline-capable edge AI workflows
5
+ Project-URL: Homepage, https://convilyn.corenovus.com
6
+ Project-URL: Documentation, https://docs.convilyn.corenovus.com
7
+ Project-URL: Issues, https://github.com/CoreNovus/convilyn-python/issues
8
+ Project-URL: Repository, https://github.com/CoreNovus/convilyn-python
9
+ Author-email: Convilyn <sdk@convilyn.corenovus.com>
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ Keywords: ai,convilyn,device,edge,iot,spi,workflow
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Topic :: System :: Hardware
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.10
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
26
+ Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
27
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
28
+ Requires-Dist: ruff==0.15.6; extra == 'dev'
29
+ Description-Content-Type: text/markdown
30
+
31
+ # convilyn-edge
32
+
33
+ The **Convilyn Edge AI Workflow SDK** — the Device Data Plane + Edge Runtime SPI
34
+ for building auditable, offline-capable edge/IoT AI workflows.
35
+
36
+ > **Alpha (`0.1.0b3`).** v0.1 ships the seven typed SPI Protocols + the Event
37
+ > Envelope + a `Result` type — with **zero runtime dependencies** — plus, landed
38
+ > across the b1–b3 betas: the `client_compute` on-device model keystone
39
+ > (`convilyn_edge.clientcompute`), the durable offline queue + emitter
40
+ > (`convilyn_edge.offline`), the device simulator + `convilyn-edge` CLI
41
+ > (`convilyn_edge.simulator` / `.cli`), and a capability `probe`. The removable
42
+ > retail Solution Pack ships as its own package
43
+ > (`convilyn-solution-retail-cashier`). Each section below documents the module
44
+ > as it exists in this release.
45
+
46
+ ## What this is (and is not)
47
+
48
+ Convilyn splits an edge AI product into three planes:
49
+
50
+ | Plane | Home |
51
+ |---|---|
52
+ | **AI Workflow Plane** — SOP lookup, explain, re-ground, HITL, escalate, gated tools + the 7 deterministic hard zones | `backend-api` (the Convilyn cloud) |
53
+ | **Device Data Plane + Edge Runtime + adapter/provider SPI** | **this package (`convilyn-edge`)** |
54
+ | **Vertical logic** — the barcode rules, POS state, workflows | a *removable* Solution Pack (`solution-retail-cashier`) |
55
+
56
+ Convilyn ships the **SPI + a simulator + reference adapters only** — never
57
+ hardware drivers or action connectors. Real OPOS/.NET, Zebra/Kotlin, serial /
58
+ MQTT / camera adapters and any device actuation beyond R0/R1 are integrator /
59
+ community work. That boundary is the moat and the anti-divergence guarantee.
60
+
61
+ **Build once, run anywhere.** Workflows are authored in Convilyn's chat-driven
62
+ **Builder** — a shared, client-agnostic capability in the AI Workflow Plane, *not*
63
+ part of this SDK. Every client (web, desktop, or device) then *runs* that same
64
+ compiled workflow (`uw_…`); the Edge SDK **consumes** workflows via its
65
+ `ModelOperator` (cloud placement wraps the consumer SDK's `client.goals.run`; edge
66
+ placement runs a local model), it never builds one.
67
+
68
+ ## The 7 primitives (`convilyn_edge.spi`)
69
+
70
+ Each is one narrow Protocol — depend on the interface, not a runtime (DIP/ISP).
71
+
72
+ | # | Primitive | Essence |
73
+ |---|---|---|
74
+ | 1 | `EventSource` | events enter the SDK → `AsyncIterator[EventEnvelope]` |
75
+ | 2 | `Normalizer[Raw, Canonical]` | raw vendor payload → canonical event (`Result`, sync) |
76
+ | 3 | `StateProvider[T]` | environment state at event time (`async`) |
77
+ | 4 | `DeterministicOperator[In, Out]` | pure, **no-LLM** rules (`Result`, **sync**) |
78
+ | 5 | `ModelOperator[In, Out]` | typed inference — `edge`/`cloud`/`auto` (**keystone**) |
79
+ | 6 | `HumanReview` | structured human-in-the-loop → typed `ReviewOutcome` |
80
+ | 7 | `ActionSink[In, Out]` | gated side effects, risk R0–R3 |
81
+
82
+ Everything crosses the SDK inside one **`EventEnvelope`** (uniform id / schema
83
+ version / correlation / ordering — the basis for dedup, replay, and audit).
84
+
85
+ ```python
86
+ from convilyn_edge import new_envelope, EventSourceRef, Ok, Err
87
+
88
+ env = new_envelope(
89
+ event_type="device.barcode.scan.received",
90
+ event_schema="convilyn://schemas/barcode-scan/v1",
91
+ source=EventSourceRef("scanner-8f-03", "opos-scanner", "0.3.1"),
92
+ data={"scanData": "4711234567890", "symbology": "EAN13"},
93
+ )
94
+ wire = env.to_wire() # camelCase JSON object
95
+ assert EventEnvelope.from_wire(wire) == env
96
+ ```
97
+
98
+ ## Client-compute — the on-device keystone (`convilyn_edge.clientcompute`)
99
+
100
+ When a cloud workflow routes the extractor role to the device, it pauses with a
101
+ `client_compute` interrupt and hands the device a **content-free** delegation
102
+ request (files by reference only). The device runs a local model over its **own**
103
+ copy of the file and returns grounded anchors; the server re-grounds them before
104
+ trusting them. `convilyn-edge` **confirms-and-consumes** that frozen contract:
105
+
106
+ ```python
107
+ import os
108
+ from convilyn import AsyncConvilyn
109
+ from convilyn_edge.clientcompute import (
110
+ ClientComputeBridge, EdgeModelOperator, HttpLocalExtractor,
111
+ )
112
+
113
+ # A local inference server (Ollama / any OpenAI-compatible endpoint), chosen by env.
114
+ operator = EdgeModelOperator(HttpLocalExtractor.from_env(os.environ))
115
+ # `resolver.resolve(file_id) -> local text` — the device reads its OWN file copy.
116
+ bridge = ClientComputeBridge(operator, resolver)
117
+
118
+ async with AsyncConvilyn() as client:
119
+ job = await client.goals.wait(job_id)
120
+ # If the cloud delegated an extract step, fulfil it locally and resume:
121
+ updated = await bridge.handle_if_present(client.goals, job)
122
+ ```
123
+
124
+ The consumer SDK is *injected* (a narrow `GoalClientPort` Protocol), never
125
+ imported — so `convilyn-edge` itself stays dependency-free. Values that aren't a
126
+ verbatim substring of the local source degrade to `"Not specified"` **on the
127
+ device**, exactly as the server would degrade them — an ungrounded (possibly
128
+ injected) string never crosses the boundary.
129
+
130
+ ## Offline-first (`convilyn_edge.offline`)
131
+
132
+ The device keeps working when the cloud is unreachable — structured events buffer
133
+ durably and flush exactly once on reconnect:
134
+
135
+ ```python
136
+ from pathlib import Path
137
+ from convilyn_edge.offline import DurableQueue, EventEmitter, event_key
138
+
139
+ queue = DurableQueue(Path("edge-events.jsonl"), key_of=event_key)
140
+ emitter = EventEmitter(sink, queue) # sink: EventSink (your HTTP/MQTT transport)
141
+
142
+ await emitter.emit(envelope) # delivered, or durably buffered if offline
143
+ report = await emitter.flush() # drain on reconnect; report.clean == True
144
+ ```
145
+
146
+ Enqueue is **idempotent** (keyed by the envelope's unique `event_id`), and
147
+ `derive_idempotency_key` reproduces the server's content-addressed reconcile key
148
+ byte-for-byte — so a retried flush is a no-op, never a duplicate.
149
+
150
+ ## CLI — simulate with no hardware (`convilyn-edge`)
151
+
152
+ A developer shouldn't need a real scanner to test a workflow. Replay a JSON
153
+ scenario through the built-in simulator:
154
+
155
+ ```bash
156
+ convilyn-edge simulate scenario.json --no-delay # prints one wire-JSON envelope per event
157
+ convilyn-edge init adapter zebra-datawedge # scaffold a device adapter
158
+ convilyn-edge init workflow cashier-guidance # scaffold a workflow
159
+ ```
160
+
161
+ A scenario declares a device and an ordered list of events (each with an optional
162
+ `delay_ms` / `repeat`); `SimulatedSource` — the first concrete `EventSource` —
163
+ replays it as an `EventEnvelope` stream. (`dev run` / `trace replay` land in v0.2
164
+ with the workflow executor; `simulate --no-delay` is the deterministic replay.)
165
+
166
+ ## Design principles (enforced in code, not just docs)
167
+
168
+ - **The device is never a second source of truth.** The server holds the 7 hard
169
+ zones and re-grounds every device value; the edge SPI inherits that contract.
170
+ - **No LLM in `DeterministicOperator`** — a *sync* signature makes "no I/O, no
171
+ model" a type-level guarantee. Scenario rules live in a removable pack.
172
+ - **One envelope, one `Result`, one observability convention.** No parallel
173
+ transports; no `if provider == ...`.
174
+
175
+ ## The litmus test
176
+
177
+ > Delete the entire retail Solution Pack. Does the remaining SDK still let you
178
+ > build another IoT AI workflow?
179
+
180
+ If yes, this is a general SDK. v0.1 (PR6) turns that question into a committed CI
181
+ lint.
182
+
183
+ ## Install
184
+
185
+ ```bash
186
+ pip install --pre convilyn-edge
187
+ ```
188
+
189
+ Python ≥ 3.10. Zero runtime dependencies. Runnable examples live in
190
+ [`examples/`](./examples/) — start with `examples/simulate_barcode.py`.
191
+
192
+ ## License
193
+
194
+ Apache-2.0.