sdcgovernance 4.0.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.
- sdcgovernance-4.0.0/LICENSE +201 -0
- sdcgovernance-4.0.0/PKG-INFO +171 -0
- sdcgovernance-4.0.0/README.md +143 -0
- sdcgovernance-4.0.0/pyproject.toml +46 -0
- sdcgovernance-4.0.0/setup.cfg +4 -0
- sdcgovernance-4.0.0/src/sdcgovernance/__init__.py +104 -0
- sdcgovernance-4.0.0/src/sdcgovernance/attestation.py +205 -0
- sdcgovernance-4.0.0/src/sdcgovernance/audit.py +12 -0
- sdcgovernance-4.0.0/src/sdcgovernance/decision.py +295 -0
- sdcgovernance-4.0.0/src/sdcgovernance/engine.py +228 -0
- sdcgovernance-4.0.0/src/sdcgovernance/mcp_server.py +488 -0
- sdcgovernance-4.0.0/src/sdcgovernance/model_inspector.py +348 -0
- sdcgovernance-4.0.0/src/sdcgovernance/party_role.py +284 -0
- sdcgovernance-4.0.0/src/sdcgovernance/provenance.py +461 -0
- sdcgovernance-4.0.0/src/sdcgovernance/receipts.py +269 -0
- sdcgovernance-4.0.0/src/sdcgovernance/shacl_runtime.py +223 -0
- sdcgovernance-4.0.0/src/sdcgovernance/workflow.py +415 -0
- sdcgovernance-4.0.0/src/sdcgovernance.egg-info/PKG-INFO +171 -0
- sdcgovernance-4.0.0/src/sdcgovernance.egg-info/SOURCES.txt +31 -0
- sdcgovernance-4.0.0/src/sdcgovernance.egg-info/dependency_links.txt +1 -0
- sdcgovernance-4.0.0/src/sdcgovernance.egg-info/entry_points.txt +2 -0
- sdcgovernance-4.0.0/src/sdcgovernance.egg-info/requires.txt +7 -0
- sdcgovernance-4.0.0/src/sdcgovernance.egg-info/top_level.txt +1 -0
- sdcgovernance-4.0.0/tests/test_attestation.py +130 -0
- sdcgovernance-4.0.0/tests/test_audit.py +16 -0
- sdcgovernance-4.0.0/tests/test_decision.py +439 -0
- sdcgovernance-4.0.0/tests/test_mcp_server.py +333 -0
- sdcgovernance-4.0.0/tests/test_model_inspector.py +169 -0
- sdcgovernance-4.0.0/tests/test_party_role.py +181 -0
- sdcgovernance-4.0.0/tests/test_provenance.py +323 -0
- sdcgovernance-4.0.0/tests/test_receipts.py +198 -0
- sdcgovernance-4.0.0/tests/test_shacl_runtime.py +248 -0
- sdcgovernance-4.0.0/tests/test_workflow.py +329 -0
|
@@ -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 reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and 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 choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or 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 [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sdcgovernance
|
|
3
|
+
Version: 4.0.0
|
|
4
|
+
Summary: W3C standards-based governance validation for Semantic Data Charter instances
|
|
5
|
+
Author: Semantic Data Charter Foundation
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://semanticdatacharter.com
|
|
8
|
+
Project-URL: Repository, https://github.com/SemanticDataCharter/sdcgovernance
|
|
9
|
+
Project-URL: Issues, https://github.com/SemanticDataCharter/sdcgovernance/issues
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: lxml>=5.0
|
|
22
|
+
Requires-Dist: rdflib>=7.0
|
|
23
|
+
Requires-Dist: pyshacl>=0.25
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
26
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# sdcgovernance
|
|
30
|
+
|
|
31
|
+
W3C standards-based governance advisory engine for Semantic Data Charter instances.
|
|
32
|
+
|
|
33
|
+
A Python library that validates governance content in XML data instances against governance components defined in the SDC data model. If the model defines governance (workflow, attestation, party/role, provenance, audit), the instance must carry that content - and this library validates it.
|
|
34
|
+
|
|
35
|
+
Returns decisions using OASIS XACML semantics: PERMIT, DENY, or INDETERMINATE.
|
|
36
|
+
|
|
37
|
+
No framework dependency. No middleware. A function call.
|
|
38
|
+
|
|
39
|
+
## How It Works
|
|
40
|
+
|
|
41
|
+
SDC data models (XSD) can optionally include governance components: Workflow state machines, Attestation authority requirements, Party/Role constraints, Provenance requirements, and Audit definitions. These are part of the data model, not a separate governance layer.
|
|
42
|
+
|
|
43
|
+
When governance components are defined, every XML data instance must carry the corresponding governance content. This library validates that content against the model:
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from sdcgovernance import validate_governance
|
|
47
|
+
|
|
48
|
+
result = validate_governance("model.xsd", "instance.xml")
|
|
49
|
+
|
|
50
|
+
print(result.decision) # PERMIT, DENY, or INDETERMINATE
|
|
51
|
+
print(result.has_governance) # True if model defines governance components
|
|
52
|
+
print(result.errors) # list of governance validation errors
|
|
53
|
+
print(result.receipt) # tamper-evident decision receipt
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
If the model does not define governance components, the result is `PERMIT` - no governance to enforce.
|
|
57
|
+
|
|
58
|
+
## Two Independent Libraries
|
|
59
|
+
|
|
60
|
+
sdcvalidator and sdcgovernance are separate, independent libraries. There is no hook, no chaining, no automatic invocation of one from the other.
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
sdcvalidator (structural validation)
|
|
64
|
+
Does the instance conform to the XSD schema?
|
|
65
|
+
Single-pass. Instance in, pass/fail out.
|
|
66
|
+
|
|
67
|
+
sdcgovernance (governance advisory)
|
|
68
|
+
Does the model define governance components?
|
|
69
|
+
If yes: does the instance carry valid governance content?
|
|
70
|
+
Conversational. Agents query multiple times during a workflow.
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Both libraries read the schema from the instance. Agents call each one independently, at different points in a workflow, in whatever order the operational logic requires. A single workflow may involve multiple calls to both libraries.
|
|
74
|
+
|
|
75
|
+
## What Gets Validated
|
|
76
|
+
|
|
77
|
+
| Component | What the model defines | What the instance must carry |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| **Workflow** | Cluster tree of valid paths (sub-clusters with XdOrdinal states) | Current XdOrdinal state, proposed transition validated against ordinal adjacency in valid paths |
|
|
80
|
+
| **Attestation** | Authority requirements per action | Attestation with correct role, party reference, timestamp |
|
|
81
|
+
| **Party/Role** | Role constraints for governed actions | Acting party identification with required role |
|
|
82
|
+
| **Provenance/Audit** | Provenance requirements (PROV-O) + retention policy (DPV) | PROV-formatted record(s) per retention policy: most recent + hash, last N, or full chain |
|
|
83
|
+
|
|
84
|
+
Governance components are discovered by **vocabulary binding**, not by CUID2 identity. Any component bound to the right standard vocabulary (PROV-O, SCXML, VC, DPV) is recognized as a governance component - whether it comes from the Default project or was custom-built.
|
|
85
|
+
|
|
86
|
+
## Enforcement Decisions (OASIS XACML)
|
|
87
|
+
|
|
88
|
+
| Decision | Meaning |
|
|
89
|
+
|---|---|
|
|
90
|
+
| **PERMIT** | All governance checks pass - action is authorized |
|
|
91
|
+
| **DENY** | One or more governance checks fail - action is refused |
|
|
92
|
+
| **INDETERMINATE** | Governance checks partially pass - requires review (configurable) |
|
|
93
|
+
|
|
94
|
+
Every decision produces a W3C PROV record and a SHA-256 hash-chained receipt.
|
|
95
|
+
|
|
96
|
+
What happens after the decision is the agent's responsibility. sdcgovernance issues the decision and the receipt. The operational response - routing, escalation, notification, halting - is customer business logic that varies per implementation.
|
|
97
|
+
|
|
98
|
+
## Two Interfaces, One Engine
|
|
99
|
+
|
|
100
|
+
**Python API** - for direct integration:
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from sdcgovernance import validate_governance
|
|
104
|
+
|
|
105
|
+
result = validate_governance("model.xsd", "instance.xml")
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**MCP Server** - for any agent framework:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
sdcgovernance serve --mcp
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The MCP server exposes governance as tools that agents call. The agent runs the loop. sdcgovernance advises.
|
|
115
|
+
|
|
116
|
+
## Standards
|
|
117
|
+
|
|
118
|
+
- **OASIS XACML** - decision semantics (PERMIT/DENY/INDETERMINATE)
|
|
119
|
+
- **SDC native structure + W3C SCXML concepts** - workflow sequencing via XdOrdinal components in sub-cluster paths, borrowing the concepts of state and transition from automata theory as specified in W3C SCXML
|
|
120
|
+
- **W3C PROV** (PROV-O, PROV-DM) - provenance/audit records (one governance dimension)
|
|
121
|
+
- **W3C Data Privacy Vocabulary (DPV)** - provenance retention policy (same vocabulary used for SDC access control)
|
|
122
|
+
- **W3C Activity Streams 2.0** - activity/event type vocabulary
|
|
123
|
+
- **W3C Verifiable Credentials Data Model 2.0** - attestation authority pattern
|
|
124
|
+
- **W3C SHACL** - cross-entity constraint validation
|
|
125
|
+
- **OMG DMN** - decision tables for complex governance rules
|
|
126
|
+
- **SHA-256** - tamper-evident hash chains for decision receipts
|
|
127
|
+
|
|
128
|
+
## Architecture
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
src/sdcgovernance/
|
|
132
|
+
├── __init__.py # Public API: validate_governance()
|
|
133
|
+
├── engine.py # GovernanceEngine - the decision engine agents query
|
|
134
|
+
├── model_inspector.py # Inspect SDC model for governance components
|
|
135
|
+
├── workflow.py # Validate workflow transitions in instance
|
|
136
|
+
├── attestation.py # Validate attestation content in instance
|
|
137
|
+
├── party_role.py # Validate party/role constraints in instance
|
|
138
|
+
├── provenance.py # Validate provenance/audit records + PROV generation + DPV retention policy
|
|
139
|
+
├── decision.py # DMN decision table evaluation
|
|
140
|
+
├── receipts.py # Decision receipt chain (hash-chained)
|
|
141
|
+
├── shacl_runtime.py # SHACL cross-entity constraint validation
|
|
142
|
+
└── mcp_server.py # MCP server exposing governance tools to any agent
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Pure Python. No Django. No middleware. No web framework dependency.
|
|
146
|
+
|
|
147
|
+
## Installation
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
pip install sdcgovernance
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Integration with SDC Ecosystem
|
|
154
|
+
|
|
155
|
+
- **sdcvalidator** - independent structural validation library. Agents call it separately from sdcgovernance, at different points in a workflow.
|
|
156
|
+
- **SDCStudio** - models governance components visually. The XSD output includes governance definitions that sdcgovernance validates against.
|
|
157
|
+
- **AppGen** - generated applications can call `validate_governance()` at data entry boundaries.
|
|
158
|
+
- **SDC Agents** - reference implementations showing how to wire governance MCP tools into agentic workflows using Default project governance models. Customer agents connect to the same MCP server and use the tools however they want.
|
|
159
|
+
|
|
160
|
+
## Status
|
|
161
|
+
|
|
162
|
+
Pre-alpha. Planning phase. See [PLANNING.md](PLANNING.md) for the architecture and implementation roadmap.
|
|
163
|
+
|
|
164
|
+
## Dependencies
|
|
165
|
+
|
|
166
|
+
- `rdflib` - RDF/PROV record generation
|
|
167
|
+
- `pyshacl` - SHACL constraint validation
|
|
168
|
+
|
|
169
|
+
## License
|
|
170
|
+
|
|
171
|
+
Apache 2.0
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# sdcgovernance
|
|
2
|
+
|
|
3
|
+
W3C standards-based governance advisory engine for Semantic Data Charter instances.
|
|
4
|
+
|
|
5
|
+
A Python library that validates governance content in XML data instances against governance components defined in the SDC data model. If the model defines governance (workflow, attestation, party/role, provenance, audit), the instance must carry that content - and this library validates it.
|
|
6
|
+
|
|
7
|
+
Returns decisions using OASIS XACML semantics: PERMIT, DENY, or INDETERMINATE.
|
|
8
|
+
|
|
9
|
+
No framework dependency. No middleware. A function call.
|
|
10
|
+
|
|
11
|
+
## How It Works
|
|
12
|
+
|
|
13
|
+
SDC data models (XSD) can optionally include governance components: Workflow state machines, Attestation authority requirements, Party/Role constraints, Provenance requirements, and Audit definitions. These are part of the data model, not a separate governance layer.
|
|
14
|
+
|
|
15
|
+
When governance components are defined, every XML data instance must carry the corresponding governance content. This library validates that content against the model:
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from sdcgovernance import validate_governance
|
|
19
|
+
|
|
20
|
+
result = validate_governance("model.xsd", "instance.xml")
|
|
21
|
+
|
|
22
|
+
print(result.decision) # PERMIT, DENY, or INDETERMINATE
|
|
23
|
+
print(result.has_governance) # True if model defines governance components
|
|
24
|
+
print(result.errors) # list of governance validation errors
|
|
25
|
+
print(result.receipt) # tamper-evident decision receipt
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
If the model does not define governance components, the result is `PERMIT` - no governance to enforce.
|
|
29
|
+
|
|
30
|
+
## Two Independent Libraries
|
|
31
|
+
|
|
32
|
+
sdcvalidator and sdcgovernance are separate, independent libraries. There is no hook, no chaining, no automatic invocation of one from the other.
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
sdcvalidator (structural validation)
|
|
36
|
+
Does the instance conform to the XSD schema?
|
|
37
|
+
Single-pass. Instance in, pass/fail out.
|
|
38
|
+
|
|
39
|
+
sdcgovernance (governance advisory)
|
|
40
|
+
Does the model define governance components?
|
|
41
|
+
If yes: does the instance carry valid governance content?
|
|
42
|
+
Conversational. Agents query multiple times during a workflow.
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Both libraries read the schema from the instance. Agents call each one independently, at different points in a workflow, in whatever order the operational logic requires. A single workflow may involve multiple calls to both libraries.
|
|
46
|
+
|
|
47
|
+
## What Gets Validated
|
|
48
|
+
|
|
49
|
+
| Component | What the model defines | What the instance must carry |
|
|
50
|
+
|---|---|---|
|
|
51
|
+
| **Workflow** | Cluster tree of valid paths (sub-clusters with XdOrdinal states) | Current XdOrdinal state, proposed transition validated against ordinal adjacency in valid paths |
|
|
52
|
+
| **Attestation** | Authority requirements per action | Attestation with correct role, party reference, timestamp |
|
|
53
|
+
| **Party/Role** | Role constraints for governed actions | Acting party identification with required role |
|
|
54
|
+
| **Provenance/Audit** | Provenance requirements (PROV-O) + retention policy (DPV) | PROV-formatted record(s) per retention policy: most recent + hash, last N, or full chain |
|
|
55
|
+
|
|
56
|
+
Governance components are discovered by **vocabulary binding**, not by CUID2 identity. Any component bound to the right standard vocabulary (PROV-O, SCXML, VC, DPV) is recognized as a governance component - whether it comes from the Default project or was custom-built.
|
|
57
|
+
|
|
58
|
+
## Enforcement Decisions (OASIS XACML)
|
|
59
|
+
|
|
60
|
+
| Decision | Meaning |
|
|
61
|
+
|---|---|
|
|
62
|
+
| **PERMIT** | All governance checks pass - action is authorized |
|
|
63
|
+
| **DENY** | One or more governance checks fail - action is refused |
|
|
64
|
+
| **INDETERMINATE** | Governance checks partially pass - requires review (configurable) |
|
|
65
|
+
|
|
66
|
+
Every decision produces a W3C PROV record and a SHA-256 hash-chained receipt.
|
|
67
|
+
|
|
68
|
+
What happens after the decision is the agent's responsibility. sdcgovernance issues the decision and the receipt. The operational response - routing, escalation, notification, halting - is customer business logic that varies per implementation.
|
|
69
|
+
|
|
70
|
+
## Two Interfaces, One Engine
|
|
71
|
+
|
|
72
|
+
**Python API** - for direct integration:
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from sdcgovernance import validate_governance
|
|
76
|
+
|
|
77
|
+
result = validate_governance("model.xsd", "instance.xml")
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**MCP Server** - for any agent framework:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
sdcgovernance serve --mcp
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
The MCP server exposes governance as tools that agents call. The agent runs the loop. sdcgovernance advises.
|
|
87
|
+
|
|
88
|
+
## Standards
|
|
89
|
+
|
|
90
|
+
- **OASIS XACML** - decision semantics (PERMIT/DENY/INDETERMINATE)
|
|
91
|
+
- **SDC native structure + W3C SCXML concepts** - workflow sequencing via XdOrdinal components in sub-cluster paths, borrowing the concepts of state and transition from automata theory as specified in W3C SCXML
|
|
92
|
+
- **W3C PROV** (PROV-O, PROV-DM) - provenance/audit records (one governance dimension)
|
|
93
|
+
- **W3C Data Privacy Vocabulary (DPV)** - provenance retention policy (same vocabulary used for SDC access control)
|
|
94
|
+
- **W3C Activity Streams 2.0** - activity/event type vocabulary
|
|
95
|
+
- **W3C Verifiable Credentials Data Model 2.0** - attestation authority pattern
|
|
96
|
+
- **W3C SHACL** - cross-entity constraint validation
|
|
97
|
+
- **OMG DMN** - decision tables for complex governance rules
|
|
98
|
+
- **SHA-256** - tamper-evident hash chains for decision receipts
|
|
99
|
+
|
|
100
|
+
## Architecture
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
src/sdcgovernance/
|
|
104
|
+
├── __init__.py # Public API: validate_governance()
|
|
105
|
+
├── engine.py # GovernanceEngine - the decision engine agents query
|
|
106
|
+
├── model_inspector.py # Inspect SDC model for governance components
|
|
107
|
+
├── workflow.py # Validate workflow transitions in instance
|
|
108
|
+
├── attestation.py # Validate attestation content in instance
|
|
109
|
+
├── party_role.py # Validate party/role constraints in instance
|
|
110
|
+
├── provenance.py # Validate provenance/audit records + PROV generation + DPV retention policy
|
|
111
|
+
├── decision.py # DMN decision table evaluation
|
|
112
|
+
├── receipts.py # Decision receipt chain (hash-chained)
|
|
113
|
+
├── shacl_runtime.py # SHACL cross-entity constraint validation
|
|
114
|
+
└── mcp_server.py # MCP server exposing governance tools to any agent
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Pure Python. No Django. No middleware. No web framework dependency.
|
|
118
|
+
|
|
119
|
+
## Installation
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
pip install sdcgovernance
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Integration with SDC Ecosystem
|
|
126
|
+
|
|
127
|
+
- **sdcvalidator** - independent structural validation library. Agents call it separately from sdcgovernance, at different points in a workflow.
|
|
128
|
+
- **SDCStudio** - models governance components visually. The XSD output includes governance definitions that sdcgovernance validates against.
|
|
129
|
+
- **AppGen** - generated applications can call `validate_governance()` at data entry boundaries.
|
|
130
|
+
- **SDC Agents** - reference implementations showing how to wire governance MCP tools into agentic workflows using Default project governance models. Customer agents connect to the same MCP server and use the tools however they want.
|
|
131
|
+
|
|
132
|
+
## Status
|
|
133
|
+
|
|
134
|
+
Pre-alpha. Planning phase. See [PLANNING.md](PLANNING.md) for the architecture and implementation roadmap.
|
|
135
|
+
|
|
136
|
+
## Dependencies
|
|
137
|
+
|
|
138
|
+
- `rdflib` - RDF/PROV record generation
|
|
139
|
+
- `pyshacl` - SHACL constraint validation
|
|
140
|
+
|
|
141
|
+
## License
|
|
142
|
+
|
|
143
|
+
Apache 2.0
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "sdcgovernance"
|
|
7
|
+
version = "4.0.0"
|
|
8
|
+
description = "W3C standards-based governance validation for Semantic Data Charter instances"
|
|
9
|
+
license = "Apache-2.0"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
readme = "README.md"
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Semantic Data Charter Foundation"},
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.10",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Topic :: Software Development :: Libraries",
|
|
23
|
+
"Topic :: Scientific/Engineering :: Information Analysis",
|
|
24
|
+
]
|
|
25
|
+
dependencies = [
|
|
26
|
+
"lxml>=5.0",
|
|
27
|
+
"rdflib>=7.0",
|
|
28
|
+
"pyshacl>=0.25",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
dev = [
|
|
33
|
+
"pytest>=8.0",
|
|
34
|
+
"pytest-cov",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[project.urls]
|
|
38
|
+
Homepage = "https://semanticdatacharter.com"
|
|
39
|
+
Repository = "https://github.com/SemanticDataCharter/sdcgovernance"
|
|
40
|
+
Issues = "https://github.com/SemanticDataCharter/sdcgovernance/issues"
|
|
41
|
+
|
|
42
|
+
[project.scripts]
|
|
43
|
+
sdcgovernance = "sdcgovernance.mcp_server:main"
|
|
44
|
+
|
|
45
|
+
[tool.setuptools.packages.find]
|
|
46
|
+
where = ["src"]
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"""
|
|
2
|
+
sdcgovernance - W3C standards-based governance advisory engine for SDC instances.
|
|
3
|
+
|
|
4
|
+
Validates governance content in XML data instances against governance
|
|
5
|
+
components defined in the SDC data model. If the model defines governance
|
|
6
|
+
(workflow, attestation, party/role, provenance/audit), the instance must
|
|
7
|
+
carry that governance content - and this library validates it.
|
|
8
|
+
|
|
9
|
+
Returns decisions using OASIS XACML semantics: PERMIT, DENY, or INDETERMINATE.
|
|
10
|
+
|
|
11
|
+
sdcgovernance is independent from sdcvalidator. Both libraries read the schema
|
|
12
|
+
from the instance. Agents call each one independently, at different points in
|
|
13
|
+
a workflow, in whatever order the operational logic requires.
|
|
14
|
+
|
|
15
|
+
No framework dependency. No middleware. A function call.
|
|
16
|
+
|
|
17
|
+
Install from PyPI::
|
|
18
|
+
|
|
19
|
+
pip install sdcgovernance
|
|
20
|
+
|
|
21
|
+
Basic usage::
|
|
22
|
+
|
|
23
|
+
from sdcgovernance import validate_governance
|
|
24
|
+
|
|
25
|
+
result = validate_governance("model.xsd", "instance.xml")
|
|
26
|
+
print(result.decision) # PERMIT, DENY, INDETERMINATE
|
|
27
|
+
print(result.errors) # list of governance validation errors
|
|
28
|
+
|
|
29
|
+
See https://github.com/SemanticDataCharter/sdcgovernance for documentation.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
__version__ = "4.0.0a1"
|
|
33
|
+
|
|
34
|
+
from sdcgovernance.engine import GovernanceEngine
|
|
35
|
+
from sdcgovernance.model_inspector import GovernanceModel, inspect_model
|
|
36
|
+
from sdcgovernance.receipts import (
|
|
37
|
+
Decision,
|
|
38
|
+
GovernanceResult,
|
|
39
|
+
Obligation,
|
|
40
|
+
Receipt,
|
|
41
|
+
ReceiptChain,
|
|
42
|
+
StatusCode,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
__all__ = [
|
|
46
|
+
"validate_governance",
|
|
47
|
+
"inspect_model",
|
|
48
|
+
"Decision",
|
|
49
|
+
"GovernanceEngine",
|
|
50
|
+
"GovernanceModel",
|
|
51
|
+
"GovernanceResult",
|
|
52
|
+
"Obligation",
|
|
53
|
+
"Receipt",
|
|
54
|
+
"ReceiptChain",
|
|
55
|
+
"StatusCode",
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def validate_governance(
|
|
60
|
+
schema_path: str,
|
|
61
|
+
instance_path: str | None = None,
|
|
62
|
+
) -> GovernanceResult:
|
|
63
|
+
"""
|
|
64
|
+
Validate governance content in an SDC instance against its model.
|
|
65
|
+
|
|
66
|
+
This is the primary public API. It inspects the model for governance
|
|
67
|
+
components and, if an instance is provided, validates the governance
|
|
68
|
+
content in the instance against the model's requirements.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
schema_path: Path to the SDC data model XSD file.
|
|
72
|
+
instance_path: Path to the XML instance file. If None, only
|
|
73
|
+
model inspection is performed (returns which governance
|
|
74
|
+
dimensions are defined).
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
GovernanceResult with XACML decision and details.
|
|
78
|
+
"""
|
|
79
|
+
# Phase 1: Model inspection
|
|
80
|
+
model = inspect_model(schema_path)
|
|
81
|
+
|
|
82
|
+
if not model.has_governance:
|
|
83
|
+
return GovernanceResult(
|
|
84
|
+
decision=Decision.NOT_APPLICABLE,
|
|
85
|
+
has_governance=False,
|
|
86
|
+
status_code=StatusCode.OK,
|
|
87
|
+
dimensions_validated=model.active_dimensions,
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
# Phase 1 without instance: report what governance exists
|
|
91
|
+
if instance_path is None:
|
|
92
|
+
return GovernanceResult(
|
|
93
|
+
decision=Decision.PERMIT,
|
|
94
|
+
has_governance=True,
|
|
95
|
+
dimensions_validated=model.active_dimensions,
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
# Instance validation will be implemented in Phases 2-4
|
|
99
|
+
# For now, return PERMIT with governance model info
|
|
100
|
+
return GovernanceResult(
|
|
101
|
+
decision=Decision.PERMIT,
|
|
102
|
+
has_governance=True,
|
|
103
|
+
dimensions_validated=model.active_dimensions,
|
|
104
|
+
)
|