lgd-engine 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.
- lgd_engine-0.1.0/LICENSE +202 -0
- lgd_engine-0.1.0/NOTICE +23 -0
- lgd_engine-0.1.0/PKG-INFO +286 -0
- lgd_engine-0.1.0/README.md +380 -0
- lgd_engine-0.1.0/lgd_engine/__init__.py +9 -0
- lgd_engine-0.1.0/lgd_engine/cli.py +116 -0
- lgd_engine-0.1.0/lgd_engine/gate/__init__.py +4 -0
- lgd_engine-0.1.0/lgd_engine/gate/engine.py +155 -0
- lgd_engine-0.1.0/lgd_engine/judges/__init__.py +18 -0
- lgd_engine-0.1.0/lgd_engine/judges/base.py +66 -0
- lgd_engine-0.1.0/lgd_engine/judges/judge_510k.py +361 -0
- lgd_engine-0.1.0/lgd_engine/judges/judge_postmarket.py +209 -0
- lgd_engine-0.1.0/lgd_engine/mcp_server.py +204 -0
- lgd_engine-0.1.0/lgd_engine/mcp_smoke.py +63 -0
- lgd_engine-0.1.0/lgd_engine/memory/__init__.py +4 -0
- lgd_engine-0.1.0/lgd_engine/memory/localmem_min.py +132 -0
- lgd_engine-0.1.0/lgd_engine.egg-info/PKG-INFO +286 -0
- lgd_engine-0.1.0/lgd_engine.egg-info/SOURCES.txt +23 -0
- lgd_engine-0.1.0/lgd_engine.egg-info/dependency_links.txt +1 -0
- lgd_engine-0.1.0/lgd_engine.egg-info/entry_points.txt +4 -0
- lgd_engine-0.1.0/lgd_engine.egg-info/requires.txt +6 -0
- lgd_engine-0.1.0/lgd_engine.egg-info/top_level.txt +1 -0
- lgd_engine-0.1.0/pyproject.toml +49 -0
- lgd_engine-0.1.0/release-prep/README.md +262 -0
- lgd_engine-0.1.0/setup.cfg +4 -0
lgd_engine-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
lgd_engine-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
LGD Engine
|
|
2
|
+
Copyright (c) 2026 Zhao, X. (Independent Researcher)
|
|
3
|
+
|
|
4
|
+
This software implements the LGD theory framework:
|
|
5
|
+
- LGD 三律 (the three laws of LGD)
|
|
6
|
+
- 有籍有证有门禁 (registered, evidenced, gated)
|
|
7
|
+
- 触点即门 (every touchpoint is a gate)
|
|
8
|
+
|
|
9
|
+
Theory attribution:
|
|
10
|
+
The judgment semantics encoded in lgd.gate and the DomainJudge classes are
|
|
11
|
+
derived from the LGD theory developed by Zhao, X. (Independent Researcher).
|
|
12
|
+
When using this engine in academic work, please cite the project as recorded
|
|
13
|
+
in the README "Citation" section. Preprint venue and citation metadata will
|
|
14
|
+
be completed at the time of submission.
|
|
15
|
+
|
|
16
|
+
Third-party components:
|
|
17
|
+
This distribution contains no vendored third-party code. Dependencies declared
|
|
18
|
+
in pyproject.toml retain their own Apache-2.0 / MIT licenses; see the SBOM
|
|
19
|
+
attached with each release.
|
|
20
|
+
|
|
21
|
+
License:
|
|
22
|
+
The code in this repository is licensed under the Apache License, Version 2.0.
|
|
23
|
+
See the LICENSE file for the full text.
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lgd-engine
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Theory-bound judgment core for medical-device AI change control (LGD 三律 / 有籍有证有门禁 / 触点即门).
|
|
5
|
+
Author: Zhao, X.
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/Medxpert-org/lgd-engine
|
|
8
|
+
Project-URL: Repository, https://github.com/Medxpert-org/lgd-engine
|
|
9
|
+
Project-URL: Issues, https://github.com/Medxpert-org/lgd-engine/issues
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/Medxpert-org/lgd-engine/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/Medxpert-org/lgd-engine/blob/main/CHANGELOG.md
|
|
12
|
+
Project-URL: Security Policy, https://github.com/Medxpert-org/lgd-engine/security/policy
|
|
13
|
+
Project-URL: Contributing, https://github.com/Medxpert-org/lgd-engine/blob/main/CONTRIBUTING.md
|
|
14
|
+
Keywords: medical devices,change control,regulatory compliance,510(k),post-market surveillance,SaMD,AI governance,decision support,MCP,model context protocol
|
|
15
|
+
Requires-Python: >=3.9
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
License-File: NOTICE
|
|
19
|
+
Provides-Extra: vector
|
|
20
|
+
Requires-Dist: fastembed>=0.3; extra == "vector"
|
|
21
|
+
Provides-Extra: yaml
|
|
22
|
+
Requires-Dist: pyyaml>=6.0; extra == "yaml"
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
# LGD Engine
|
|
26
|
+
|
|
27
|
+
<!-- mcp-name: io.github.Medxpert-org/lgd-engine -->
|
|
28
|
+
|
|
29
|
+
[]()
|
|
30
|
+
[]()
|
|
31
|
+
[]()
|
|
32
|
+
[](https://github.com/Medxpert-org/lgd-engine/actions/workflows/gate.yml)
|
|
33
|
+
[](https://github.com/Medxpert-org/lgd-engine/actions/workflows/codeql.yml)
|
|
34
|
+
|
|
35
|
+
**LGD Engine is the judgment core for medical-device AI change control.**
|
|
36
|
+
While general agent frameworks orchestrate LLMs, LGD Engine supplies the
|
|
37
|
+
*theory-bound gate*: every change verdict is produced by an auditable,
|
|
38
|
+
offline-testable judgment chain grounded in the LGD theory (three laws,
|
|
39
|
+
有籍有证有门禁 / registered-evidenced-gated, 触点即门 / every touchpoint
|
|
40
|
+
is a gate). Zero runtime dependencies — the core gate runs with no LLM.
|
|
41
|
+
|
|
42
|
+
## Quickstart
|
|
43
|
+
|
|
44
|
+
Shortest path — clone, run the gold tests, get your first verdict, then
|
|
45
|
+
wire it to your agent host:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
git clone https://github.com/Medxpert-org/lgd-engine.git
|
|
49
|
+
cd lgd-engine
|
|
50
|
+
python -m demo1.change_gate --case demo1/cases/case01_red_pma_process.json
|
|
51
|
+
# exit code: 0 = go, 1 = hold, 2 = reject
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Verify the whole gate before trusting it (stock Python 3.9+, stdlib only):
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# Windows
|
|
58
|
+
.\demo1\run_demo1.ps1 # 5/5 + 6/6 change-gate self-tests
|
|
59
|
+
.\demo2\run_demo2.ps1 # 26/26 five-seat review self-tests
|
|
60
|
+
|
|
61
|
+
# Any OS
|
|
62
|
+
python demo1/test_demo1.py # change-gate gold tests
|
|
63
|
+
python demo2/test_demo2.py # five-seat review tests
|
|
64
|
+
python framework/gate_bot.py # CI gate (six checks)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
One decision from a case JSON:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
python -m demo1.change_gate --all
|
|
71
|
+
python -m demo1.change_gate --case demo1/cases_jurisdiction/supplier_swap.json --jurisdiction NMPA
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Editable install (optional) exposes the console script:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pip install -e . # then use `lgd-gate` (see pyproject [project.scripts])
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Then point your MCP client at it — copy-paste configs are in
|
|
81
|
+
[Interface layer](#interface-layer-beta) below.
|
|
82
|
+
|
|
83
|
+
## Architecture
|
|
84
|
+
|
|
85
|
+
Layered design — adapters on the outside, judgment core in the middle,
|
|
86
|
+
fully offline:
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
L0 AI hosts (Claude Desktop, Cursor, agents)
|
|
90
|
+
│ stdio / (streamable-HTTP in 0.1)
|
|
91
|
+
▼
|
|
92
|
+
L1 lgd.gate ── aggregation core (GateEngine + GateReport)
|
|
93
|
+
│
|
|
94
|
+
├── L1.5 skill registry (skill.yaml manifest)
|
|
95
|
+
│
|
|
96
|
+
▼
|
|
97
|
+
L2 DomainJudge ×13+ (offline, gold-tested; 2 shipped: 510(k), post-market)
|
|
98
|
+
▲
|
|
99
|
+
│ evidence: precedents / cases / regulation citations
|
|
100
|
+
L3 lgd_engine/theory/laws.yaml (declarative three-law rules)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Runnable surfaces today: `python -m demo1.web` serves a local web UI +
|
|
104
|
+
JSON endpoint (POST `http://127.0.0.1:8765/judge`) that returns the exact
|
|
105
|
+
`GateReport` shape the frozen OpenAPI contract defines.
|
|
106
|
+
|
|
107
|
+
See the framework drafts for the registry and adapter specs:
|
|
108
|
+
`framework/skill-manifest-spec.md`, `framework/plugin-adapter.md`,
|
|
109
|
+
`framework/ecosystem-map.md` (11 stages × 8 jurisdictions).
|
|
110
|
+
|
|
111
|
+
## Interface layer (Beta)
|
|
112
|
+
|
|
113
|
+
Four contract surfaces are in the trunk; all are local-trust adapters
|
|
114
|
+
until the public 0.1 release wires production endpoints (TLS, auth).
|
|
115
|
+
|
|
116
|
+
| Interface | Transport / entry | Run it | Verify it |
|
|
117
|
+
|---|---|---|---|
|
|
118
|
+
| REST (demo) | stdlib HTTP, `127.0.0.1:8765`, `POST /judge` | `python -m demo1.web` | `curl -X POST http://127.0.0.1:8765/judge -H 'Content-Type: application/json' -d @demo1/cases/case01_red_pma_process.json` |
|
|
119
|
+
| REST contract | OpenAPI 3.1, `docs/openapi.yaml` (`/v1/judge`, `/v1/decisions`) | — | `python docs/validate_openapi.py` (17/17 checks, stdlib) |
|
|
120
|
+
| SSE event stream | tails append-only `demo2/events.jsonl`, 6 event types | `python -m demo2.sse_server --port 8770 --smoke` | exits 0 after asserting all 6 types |
|
|
121
|
+
| MCP server (stdio) | `lgd_engine/mcp_server.py` | `python lgd_engine/mcp_smoke.py` | smoke exercises initialize / tools list / judge / RBAC-deny (denied → -32003) |
|
|
122
|
+
| TypeScript SDK | `lgd-engine-ts/` (zero-dep types mirroring OpenAPI) | `cd lgd-engine-ts && npm run smoke` | Node 18+; smoke exits 0 |
|
|
123
|
+
| Container | `Dockerfile` + `docker-compose.yml` | `docker compose up` | REST demo on `127.0.0.1:18090` — NOT VERIFIED in the 2026-11-04 review (no Docker on the reviewing host, no container step in CI) |
|
|
124
|
+
|
|
125
|
+
> Contract status note: `docs/openapi.yaml` freezes the production wire
|
|
126
|
+
> shape (`/v1/*`, TLS, bearer auth). No `/v1` service exists in the tree
|
|
127
|
+
> yet — `demo1/web.py` (`/judge`, no `/v1` prefix) is the behavioral
|
|
128
|
+
> reference for request/response semantics.
|
|
129
|
+
|
|
130
|
+
### MCP client config (copy-paste, local-trust)
|
|
131
|
+
|
|
132
|
+
Run the server from a clone for now; from the public 0.1 release,
|
|
133
|
+
`pip install lgd-engine` provides the `lgd-engine-mcp` console entry
|
|
134
|
+
(equivalent to `python -m lgd_engine.mcp_server`). Both forms resolve
|
|
135
|
+
all internal paths from the package itself, so no specific working
|
|
136
|
+
directory is required.
|
|
137
|
+
|
|
138
|
+
Claude Desktop — `claude_desktop_config.json`
|
|
139
|
+
(Settings → Developer → Edit Config):
|
|
140
|
+
|
|
141
|
+
```json
|
|
142
|
+
{
|
|
143
|
+
"mcpServers": {
|
|
144
|
+
"lgd-engine": {
|
|
145
|
+
"command": "python",
|
|
146
|
+
"args": ["-m", "lgd_engine.mcp_server"]
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Cursor — `.cursor/mcp.json` at your project root, or use the bundled
|
|
153
|
+
`.cursor-plugin/plugin.json` (declares the same stdio server for the
|
|
154
|
+
Cursor plugin host):
|
|
155
|
+
|
|
156
|
+
```json
|
|
157
|
+
{
|
|
158
|
+
"mcpServers": {
|
|
159
|
+
"lgd-engine": {
|
|
160
|
+
"command": "python",
|
|
161
|
+
"args": ["-m", "lgd_engine.mcp_server"]
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Platform notes:
|
|
168
|
+
- Windows: `python` (or `py -3`); macOS/Linux: `python3` — replace the
|
|
169
|
+
`command` value accordingly, or use the absolute path of your interpreter.
|
|
170
|
+
- The server binds stdio locally and trusts the caller's role claim
|
|
171
|
+
(local-trust adapter, no network authentication boundary) — production
|
|
172
|
+
wiring is scheduled for the public 0.1 release.
|
|
173
|
+
- streamable-HTTP: the 0.1 release will also expose a streamable-HTTP
|
|
174
|
+
endpoint; client config will then use `"url"` instead of
|
|
175
|
+
`command`/`args`.
|
|
176
|
+
|
|
177
|
+
## The LGD Foundation
|
|
178
|
+
|
|
179
|
+
LGD Engine is not a hollow scaffold: it is the executable expression of a
|
|
180
|
+
complete theory-and-evidence stack, all distilled into runnable rules.
|
|
181
|
+
|
|
182
|
+
The judgment chain is grounded in three laws:
|
|
183
|
+
|
|
184
|
+
1. **有籍 · Registered** — every judgment is tied to a registered context:
|
|
185
|
+
a device record, a predicate, a case identifier. No context, no verdict.
|
|
186
|
+
2. **有证 · Evidenced** — every decision rule must cite evidence (a
|
|
187
|
+
precedent id, a case entry, a regulation citation). A `go` with zero
|
|
188
|
+
evidence refs is downgraded to `hold`.
|
|
189
|
+
3. **有门禁 · Gated** — every touchpoint is a gate (触点即门): release
|
|
190
|
+
decisions, agent tool calls, MCP invocations and CI pushes all pass
|
|
191
|
+
through the same three-state gate (`go` / `hold` / `reject`).
|
|
192
|
+
|
|
193
|
+
The rest of the stack:
|
|
194
|
+
|
|
195
|
+
- **Theory** — the doctrine, specified as declarative rules in
|
|
196
|
+
`lgd_engine/theory/laws.yaml` (law, trigger predicates, gate action).
|
|
197
|
+
- **Published work** — a publication line (records registered with
|
|
198
|
+
DataCite) that grounds the doctrine in medical-device change control and
|
|
199
|
+
AI-agent governance; the paper accompanying this repository is under
|
|
200
|
+
preparation and its self-citations are placeholders until registration.
|
|
201
|
+
- **Verified precedents** — change-classification precedents (MAJ/MOD/MIN,
|
|
202
|
+
including FDA recall events such as Z-1924-2025 and Z-0893-2026) and a
|
|
203
|
+
library of real change-control cases, distilled into the judge rules
|
|
204
|
+
under `lgd_engine/judges/`.
|
|
205
|
+
- **13-domain judgment knowledge** — clinical evaluation, postmarket
|
|
206
|
+
surveillance, UDI, SaMD and more, mapped onto the 11-stage medical-device
|
|
207
|
+
ecosystem (see `framework/ecosystem-map.md` and
|
|
208
|
+
`framework/eco-regulatory-matrix.md`, 11 stages × 8 jurisdictions). Two
|
|
209
|
+
domain judges are implemented in this release (510(k) change
|
|
210
|
+
classification, post-market); the remaining domains are roadmap adapters.
|
|
211
|
+
- **International alignment** — the roadmap tracks the ITU FG-TIDA and W3C
|
|
212
|
+
AI-agent memory/interop threads, so the rules follow where global
|
|
213
|
+
standards are heading.
|
|
214
|
+
|
|
215
|
+
Every judge carries an explicit evidence source, making the chain
|
|
216
|
+
theory → code → verifiable test (enforced in CI).
|
|
217
|
+
|
|
218
|
+
## Gate bot (CI) & security baseline
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
python framework/gate_bot.py # exit 0 = PASS, exit 1 = FAIL
|
|
222
|
+
powershell -File framework/gate.ps1 # Windows wrapper
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Checks: offline gold tests, LICENSE/NOTICE present, no plaintext keys,
|
|
226
|
+
manifest syntax (including adversarial re-checks: path-traversal manifest
|
|
227
|
+
entries and known secret shapes are rejected).
|
|
228
|
+
|
|
229
|
+
`security/security_baseline.md` maps OWASP Top 10 (2021) and OWASP Top 10
|
|
230
|
+
for LLM Applications (2025) to concrete defenses in this tree;
|
|
231
|
+
`python security/security_scan.py` re-checks the tree before every release.
|
|
232
|
+
|
|
233
|
+
## Verified test evidence (2026-11-03)
|
|
234
|
+
|
|
235
|
+
- demo1 change-gate gold tests: **5/5 PASS**; demo2 five-seat review: **26/26 PASS**
|
|
236
|
+
- `framework/gate_bot.py`: **6/6 checks PASS**; `security/security_scan.py`: **clean, 0 findings**
|
|
237
|
+
- MCP smoke (tools list + judge + RBAC deny): **PASS**; SSE smoke: **6/6 event types**
|
|
238
|
+
- GitHub Actions: `gate` CI and `CodeQL` **green on main**; Dependabot enabled;
|
|
239
|
+
branch protection active (PR required + gate status check)
|
|
240
|
+
- Pre-release review: `release-prep/PRE_RELEASE_REVIEW.md` — red-team, outsider and
|
|
241
|
+
external-AI results, open findings included. The earlier "7-dimension review
|
|
242
|
+
closed, no open high-severity findings (LGD-EVAL-2026-009)" line was removed:
|
|
243
|
+
no report artifact ever backed it, and the S7 red team contradicted it.
|
|
244
|
+
|
|
245
|
+
## Repository map
|
|
246
|
+
|
|
247
|
+
- Theory rules: `lgd_engine/theory/laws.yaml`
|
|
248
|
+
- Judges: `lgd_engine/judges/` (base, 510(k) change classification, post-market)
|
|
249
|
+
- Gate engine: `lgd_engine/gate/engine.py` — Python API:
|
|
250
|
+
`GateEngine().register(Judge510kChange()).evaluate({...})` →
|
|
251
|
+
`{verdict, reasons, per_judge, law_enforcements, evidence}`
|
|
252
|
+
- Framework docs: `framework/skill-manifest-spec.md`, `framework/plugin-adapter.md`,
|
|
253
|
+
`framework/ecosystem-map.md`, `framework/13domains-mapping.md`
|
|
254
|
+
- LLM/agent-friendly summary: **[`llms.txt`](llms.txt)** (the llms.txt
|
|
255
|
+
convention entry point for agents cloning this repo)
|
|
256
|
+
|
|
257
|
+
## Contributing
|
|
258
|
+
|
|
259
|
+
PRs welcome. Before opening one:
|
|
260
|
+
|
|
261
|
+
1. Run `python framework/gate_bot.py` — it must exit 0.
|
|
262
|
+
2. Every new judge or rule must ship with a gold test and an explicit
|
|
263
|
+
evidence source (precedent id / case entry / regulation citation);
|
|
264
|
+
a `go` verdict with zero evidence refs is rejected by the gate.
|
|
265
|
+
3. Keep the core offline and stdlib-only at MVP — optional extras go in
|
|
266
|
+
`[project.optional-dependencies]`.
|
|
267
|
+
|
|
268
|
+
## Citation
|
|
269
|
+
|
|
270
|
+
```
|
|
271
|
+
@misc{zhao_lgd_engine_2026,
|
|
272
|
+
author = {Zhao, X.},
|
|
273
|
+
title = {LGD Engine: A Theory-Bound Judgment Core for Medical-Device AI Change Control},
|
|
274
|
+
year = {2026},
|
|
275
|
+
note = {Preprint placeholder — to be completed upon submission}
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
## Author
|
|
280
|
+
|
|
281
|
+
**Zhao, X. (Independent Researcher)**
|
|
282
|
+
|
|
283
|
+
## License & Notice
|
|
284
|
+
|
|
285
|
+
Code: Apache License 2.0 — see `LICENSE`.
|
|
286
|
+
Theory attribution and provenance: see `NOTICE`.
|