scyvera 1.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.
- scyvera-1.0.0/LICENSE +21 -0
- scyvera-1.0.0/PKG-INFO +319 -0
- scyvera-1.0.0/README.md +290 -0
- scyvera-1.0.0/pyproject.toml +68 -0
- scyvera-1.0.0/setup.cfg +4 -0
- scyvera-1.0.0/src/scyvera/__init__.py +51 -0
- scyvera-1.0.0/src/scyvera/builder.py +296 -0
- scyvera-1.0.0/src/scyvera/cli.py +290 -0
- scyvera-1.0.0/src/scyvera/enforcer.py +606 -0
- scyvera-1.0.0/src/scyvera/exceptions.py +81 -0
- scyvera-1.0.0/src/scyvera/linter.py +184 -0
- scyvera-1.0.0/src/scyvera/schemas/v1/contract.schema.json +102 -0
- scyvera-1.0.0/src/scyvera/schemas/v1.1/contract.schema.json +423 -0
- scyvera-1.0.0/src/scyvera/validator.py +233 -0
- scyvera-1.0.0/src/scyvera.egg-info/PKG-INFO +319 -0
- scyvera-1.0.0/src/scyvera.egg-info/SOURCES.txt +27 -0
- scyvera-1.0.0/src/scyvera.egg-info/dependency_links.txt +1 -0
- scyvera-1.0.0/src/scyvera.egg-info/entry_points.txt +2 -0
- scyvera-1.0.0/src/scyvera.egg-info/requires.txt +6 -0
- scyvera-1.0.0/src/scyvera.egg-info/top_level.txt +1 -0
- scyvera-1.0.0/tests/test_builder.py +65 -0
- scyvera-1.0.0/tests/test_cli.py +117 -0
- scyvera-1.0.0/tests/test_enforcer.py +431 -0
- scyvera-1.0.0/tests/test_filename_enforcement.py +75 -0
- scyvera-1.0.0/tests/test_lifecycle.py +179 -0
- scyvera-1.0.0/tests/test_linter.py +81 -0
- scyvera-1.0.0/tests/test_schemas_sync.py +29 -0
- scyvera-1.0.0/tests/test_validator.py +53 -0
- scyvera-1.0.0/tests/test_validator_v1_1.py +119 -0
scyvera-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shinjan Das
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
scyvera-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: scyvera
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Framework-independent contracts and validation tooling for AI agents and automated workflows.
|
|
5
|
+
Author: Shinjan Das
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/Skull-boy/agent-contracts
|
|
8
|
+
Project-URL: Issues, https://github.com/Skull-boy/agent-contracts/issues
|
|
9
|
+
Keywords: agent,contracts,governance,validation,schema,specification,automation,workflow
|
|
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: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: PyYAML<7.0,>=6.0
|
|
24
|
+
Requires-Dist: jsonschema<5.0,>=4.20
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
27
|
+
Requires-Dist: build>=1.0; extra == "dev"
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
<div align="center">
|
|
31
|
+
|
|
32
|
+
<img src="assets/logo.png" width="450" alt="agent-contracts"/>
|
|
33
|
+
|
|
34
|
+
# Scyvera
|
|
35
|
+
|
|
36
|
+
**Machine-readable, domain-independent, and framework-independent operational contracts for AI agents and automated systems.**
|
|
37
|
+
|
|
38
|
+
MCP and A2A standardize how agents communicate with tools and each other. `Scyvera` defines the layer above: what an intelligent system can do, what resources it can access, what authority it requires, what constraints apply, what side effects it produces, and how it is governed.
|
|
39
|
+
|
|
40
|
+

|
|
41
|
+

|
|
42
|
+

|
|
43
|
+

|
|
44
|
+
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## π§© What This Actually Is
|
|
51
|
+
|
|
52
|
+
`Scyvera` provides a machine-readable specification and Python tooling layer for defining the operational boundary of intelligent or automated systems.
|
|
53
|
+
|
|
54
|
+
It is **NOT**:
|
|
55
|
+
- another agent framework
|
|
56
|
+
- an LLM wrapper
|
|
57
|
+
- an orchestration library
|
|
58
|
+
- a coding-agent framework
|
|
59
|
+
- a security sandbox or malware scanner
|
|
60
|
+
|
|
61
|
+
It **IS**:
|
|
62
|
+
A framework-independent and domain-independent specification layer describing system identity, capabilities, resources, inputs, outputs, permissions, constraints, side effects, approvals, dependencies, state persistence, failure recovery, replay semantics, observability, artifact trust declarations, and risk.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## π‘οΈ Validation vs. Runtime Enforcement
|
|
67
|
+
|
|
68
|
+
Scyvera provides two complementary governance layers:
|
|
69
|
+
|
|
70
|
+
| Layer | Component | Responsibility | Trust Level |
|
|
71
|
+
|---|---|---|---|
|
|
72
|
+
| **Tier 1 & 2: Static Verification** | `validate_contract()`, `lint_contract()` | Validates that a `contract.yaml` is structurally and semantically well-formed against specification schemas. | Declaration conformance |
|
|
73
|
+
| **Runtime Enforcement** | `ContractEnforcer` | Gates real-world Python calls against declared permissions and side effects using **Default-Deny** rules. Halts execution on approval points. | Execution boundary enforcement |
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## β‘ Quickstart
|
|
78
|
+
|
|
79
|
+
### 1. Installation
|
|
80
|
+
|
|
81
|
+
Install locally or in your project virtualenv:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pip install scyvera
|
|
85
|
+
# Or for local development:
|
|
86
|
+
pip install -e .
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 2. Command-Line Interface (CLI)
|
|
90
|
+
|
|
91
|
+
#### Create a starter Contract template (v1.1)
|
|
92
|
+
```bash
|
|
93
|
+
scyvera init contract.yaml --name "Research Assistant"
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Interactive wizard mode:
|
|
97
|
+
```bash
|
|
98
|
+
scyvera init contract.yaml -i
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
#### Validate an Agent Contract
|
|
102
|
+
The CLI automatically detects the specification version (`1` vs `1.1`) and validates against the corresponding JSON Schema:
|
|
103
|
+
```bash
|
|
104
|
+
scyvera validate contract.yaml
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Output:
|
|
108
|
+
```text
|
|
109
|
+
PASS contract.yaml
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Override with a custom JSON Schema file:
|
|
113
|
+
```bash
|
|
114
|
+
scyvera validate contract.yaml --schema path/to/custom.schema.json
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## π Runtime Enforcer Quickstart
|
|
120
|
+
|
|
121
|
+
The `ContractEnforcer` protects your agent's execution boundaries in Python by enforcing **Default-Deny**: any undeclared permission or side effect raises `ContractViolationError`, and any action listed in `approval_points` raises `ApprovalPendingError`.
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
from pathlib import Path
|
|
125
|
+
from scyvera import ContractEnforcer, ContractViolationError, ApprovalPendingError
|
|
126
|
+
|
|
127
|
+
# 1. Load, validate, and freeze the contract
|
|
128
|
+
enforcer = ContractEnforcer.load("implementations/n8n/duplicate-issue-detector/contract.yaml")
|
|
129
|
+
|
|
130
|
+
# 2. Gate sensitive tools and operations
|
|
131
|
+
@enforcer.gate(action_name="github: issues:write", action_type="permission")
|
|
132
|
+
def post_github_comment(issue_id: int, comment: str):
|
|
133
|
+
print(f"Posting comment to issue #{issue_id}: {comment}")
|
|
134
|
+
return True
|
|
135
|
+
|
|
136
|
+
@enforcer.gate(action_name="aws_s3:read", action_type="permission")
|
|
137
|
+
def read_s3_bucket():
|
|
138
|
+
return "s3_data"
|
|
139
|
+
|
|
140
|
+
# 3. Allowed calls execute cleanly and log to audit trail
|
|
141
|
+
post_github_comment(101, "Potential duplicate detected.")
|
|
142
|
+
|
|
143
|
+
# 4. Undeclared actions are denied immediately (Default-Deny)
|
|
144
|
+
try:
|
|
145
|
+
read_s3_bucket()
|
|
146
|
+
except ContractViolationError as e:
|
|
147
|
+
print(f"Blocked by Scyvera: {e}")
|
|
148
|
+
|
|
149
|
+
# 5. Inspect the immutable audit log
|
|
150
|
+
for entry in enforcer.get_audit_log():
|
|
151
|
+
print(f"[{entry.timestamp}] {entry.decision} - {entry.action_name} ({entry.reason})")
|
|
152
|
+
|
|
153
|
+
# 6. Verify file integrity on disk (Threat T5 defense)
|
|
154
|
+
enforcer.verify_integrity() # Raises ContractTamperError if contract.yaml was modified
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## β οΈ What Scyvera Does Not Guarantee
|
|
160
|
+
|
|
161
|
+
Scyvera provides structural verification and runtime gating, but security is an end-to-end discipline. Integrators must understand the following technical boundaries:
|
|
162
|
+
|
|
163
|
+
1. **Gate Bypass (Threat T4)**: Scyvera enforces boundaries at the `@enforcer.gate(...)` decorator. In Python, the runtime cannot physically prevent code from directly calling an un-decorated internal function. Integrators should use `ContractEnforcer.assert_gated(fn)` within their integration test suites to verify that all external-facing tool call sites are wrapped.
|
|
164
|
+
2. **Internal Third-Party Behavior / String Spoofing (Threat T6)**: Scyvera verifies that a declared intent (e.g. `github:issues:write`) matches an allowed permission in the contract. It does not perform dynamic bytecode analysis or network-packet inspection to guarantee that a decorated library function does not execute unauthorized background calls. The integrity of third-party dependencies remains the responsibility of dependency scanning and peer review.
|
|
165
|
+
3. **Pre-Load File Tampering (Threat T5)**: The SHA-256 integrity check in `verify_integrity()` protects against file replacement AFTER load. It does not protect against a tampered `contract.yaml` being present BEFORE `ContractEnforcer.load()` is called. The deployment environment is responsible for protecting the contract file prior to load.
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
You can programmatically construct, inspect, serialize, and validate Agent Contracts in Python without manually writing YAML:
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
from scyvera import Contract, validate_contract
|
|
173
|
+
|
|
174
|
+
# Programmatically construct a v1.1 Contract
|
|
175
|
+
contract = (
|
|
176
|
+
Contract(name="Literature Research Assistant", purpose="Analyzes scientific papers")
|
|
177
|
+
.set_domain("research")
|
|
178
|
+
.add_capability("search_documents", description="Queries research repositories")
|
|
179
|
+
.add_resource("paper_db", type="pdf_repository", access="read")
|
|
180
|
+
.add_input("research_topic", type="string", required=True)
|
|
181
|
+
.add_output("summary", type="document")
|
|
182
|
+
.add_permission("paper_db", actions=["read", "search"])
|
|
183
|
+
.set_state("session")
|
|
184
|
+
.set_recovery("retry")
|
|
185
|
+
.set_replay("idempotent")
|
|
186
|
+
.set_observability("basic")
|
|
187
|
+
.set_risk("low", category="misinformation_risk")
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
# Validate directly in code
|
|
191
|
+
result = contract.validate()
|
|
192
|
+
|
|
193
|
+
if result.valid:
|
|
194
|
+
print("Contract is valid!")
|
|
195
|
+
# Save to file
|
|
196
|
+
contract.save("contract.yaml")
|
|
197
|
+
else:
|
|
198
|
+
for err in result.errors:
|
|
199
|
+
print(f"Error at {err.path}: {err.message}")
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Validate an existing YAML file programmatically:
|
|
203
|
+
```python
|
|
204
|
+
from scyvera import validate_contract
|
|
205
|
+
|
|
206
|
+
result = validate_contract("contract.yaml")
|
|
207
|
+
print(f"Valid: {result.valid}")
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## π Every Implementation Documents a Contract
|
|
213
|
+
|
|
214
|
+
Instead of prose documentation alone, systems in this repository specify:
|
|
215
|
+
|
|
216
|
+
- **Identity & Purpose** β system identity, operational scope, and system version
|
|
217
|
+
- **Capabilities** β semantic ability claims
|
|
218
|
+
- **Resources** β data stores, APIs, entities, or systems accessed
|
|
219
|
+
- **Inputs & Outputs** β data entering and produced by the system
|
|
220
|
+
- **Permissions** β exact authorized `{resource, actions[]}` combinations
|
|
221
|
+
- **Constraints** β quantitative limits (e.g. rate limits, transaction caps)
|
|
222
|
+
- **Side Effects** β externally observable mutations
|
|
223
|
+
- **Approvals** β explicit human or expert approval gates
|
|
224
|
+
- **Dependencies** β required external services, models, APIs
|
|
225
|
+
- **State, Recovery, Replay, Observability** β persistence, failure strategy, idempotency, and audit evidence
|
|
226
|
+
- **Artifact Security & Risk** β model/data artifact trust requirements and risk level classification
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## π Repository Structure
|
|
231
|
+
|
|
232
|
+
```text
|
|
233
|
+
agent-contracts/
|
|
234
|
+
βββ README.md
|
|
235
|
+
βββ WORKFLOW-CONTRACT-SPEC.md
|
|
236
|
+
βββ CONTRIBUTING.md
|
|
237
|
+
βββ CONTRIBUTORS.md
|
|
238
|
+
βββ LICENSE
|
|
239
|
+
βββ pyproject.toml
|
|
240
|
+
βββ docs/
|
|
241
|
+
β βββ contract-model-v1.1.md # Normative v1.1 Specification
|
|
242
|
+
β βββ vision.md # Strategic Project Vision
|
|
243
|
+
β βββ design-principles.md # Normative Design Principles
|
|
244
|
+
β βββ terminology.md # Specification Terminology
|
|
245
|
+
βββ schemas/
|
|
246
|
+
β βββ v1/ # Contract v1 JSON Schema
|
|
247
|
+
β β βββ contract.schema.json
|
|
248
|
+
β βββ v1.1/ # Contract v1.1 JSON Schema
|
|
249
|
+
β βββ contract.schema.json
|
|
250
|
+
βββ examples/
|
|
251
|
+
β βββ v1.1/ # Domain-Neutral Examples (v1.1)
|
|
252
|
+
β βββ education-tutor.yaml
|
|
253
|
+
β βββ research-assistant.yaml
|
|
254
|
+
β βββ financial-operations.yaml
|
|
255
|
+
β βββ clinical-information-assistant.yaml
|
|
256
|
+
βββ src/
|
|
257
|
+
β βββ scyvera/ # Python Package
|
|
258
|
+
β βββ __init__.py
|
|
259
|
+
β βββ builder.py # Programmatic Contract Builder API
|
|
260
|
+
β βββ validator.py # Multi-Version Validator Engine
|
|
261
|
+
β βββ cli.py # CLI Application (validate, init)
|
|
262
|
+
β βββ schemas/ # Bundled Package Schemas
|
|
263
|
+
βββ tests/
|
|
264
|
+
β βββ fixtures/ # Test Fixture Files
|
|
265
|
+
β βββ test_validator.py # v1 Validator Unit Tests
|
|
266
|
+
β βββ test_validator_v1_1.py # v1.1 Validator Unit Tests
|
|
267
|
+
β βββ test_builder.py # Programmatic Builder Unit Tests
|
|
268
|
+
β βββ test_cli.py # CLI Unit Tests
|
|
269
|
+
βββ implementations/ # Multi-Framework Reference Implementations
|
|
270
|
+
βββ n8n/
|
|
271
|
+
βββ langgraph/
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## π Domain-Neutral Example Contracts (v1.1)
|
|
277
|
+
|
|
278
|
+
See [`examples/v1.1/`](./examples/v1.1) for runnable, validated v1.1 contracts across different domains:
|
|
279
|
+
|
|
280
|
+
| Domain | Contract File | Description |
|
|
281
|
+
|---|---|---|
|
|
282
|
+
| **Education** | [`education-tutor.yaml`](./examples/v1.1/education-tutor.yaml) | Guided study tutor, low risk, session state |
|
|
283
|
+
| **Research** | [`research-assistant.yaml`](./examples/v1.1/research-assistant.yaml) | Scientific literature analysis, arXiv API dependency |
|
|
284
|
+
| **Finance** | [`financial-operations.yaml`](./examples/v1.1/financial-operations.yaml) | Critical risk, payment caps ($5000 USD limit), controller approval gate |
|
|
285
|
+
| **Healthcare** | [`clinical-information-assistant.yaml`](./examples/v1.1/clinical-information-assistant.yaml) | High risk, EHR database access, physician approval gate, model integrity requirements |
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
## π Security & Governance Boundary Notice
|
|
290
|
+
|
|
291
|
+
> [!IMPORTANT]
|
|
292
|
+
> **Contract Declaration β Security Verification β Runtime Enforcement.**
|
|
293
|
+
> An Agent Contract describes declared operational boundaries. It is not a sandbox, anti-malware scanner, or runtime enforcement proxy. Contract declarations provide structured input upon which external policy engines, verification scanners, and runtime isolation systems operate.
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## πΊοΈ Where the Spec Is Headed (v1.1)
|
|
298
|
+
|
|
299
|
+
Contract v1 was designed and proven against coding/developer agents. That's now understood to be a starting substrate, not the ceiling β v1.1 is a deliberate audit-and-redesign effort to make the spec:
|
|
300
|
+
|
|
301
|
+
- **Domain-independent** β usable for research, education, finance, business-workflow, and healthcare-workflow agents, not just coding agents
|
|
302
|
+
- **Framework-independent** β already true in principle (n8n + LangGraph prove it), being stress-tested further
|
|
303
|
+
- **Accessible to non-technical authors** β YAML/JSON is a representation format, not meant to be the only way to create a contract
|
|
304
|
+
|
|
305
|
+
This is genuinely in the design/audit phase β classifying existing Contract v1 fields, testing them against non-coding agent archetypes, and only then extending the schema. Nothing in this section describes a shipped feature. Follow progress in [`implementations/rfcs/`](./implementations/rfcs) and open issues tagged `v1.1`.
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
## π€ Contributing
|
|
310
|
+
|
|
311
|
+
Contributions are welcome β new domain profiles, framework reference implementations, specification RFCs, or Python API improvements. See [CONTRIBUTING.md](./CONTRIBUTING.md) for details.
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
## π License
|
|
316
|
+
|
|
317
|
+
Distributed under the MIT License β see [LICENSE](./LICENSE) for details.
|
|
318
|
+
|
|
319
|
+
Built and maintained by [Shinjan Das](https://github.com/Skull-boy) and open-source contributors β see [CONTRIBUTORS.md](./CONTRIBUTORS.md).
|
scyvera-1.0.0/README.md
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<img src="assets/logo.png" width="450" alt="agent-contracts"/>
|
|
4
|
+
|
|
5
|
+
# Scyvera
|
|
6
|
+
|
|
7
|
+
**Machine-readable, domain-independent, and framework-independent operational contracts for AI agents and automated systems.**
|
|
8
|
+
|
|
9
|
+
MCP and A2A standardize how agents communicate with tools and each other. `Scyvera` defines the layer above: what an intelligent system can do, what resources it can access, what authority it requires, what constraints apply, what side effects it produces, and how it is governed.
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+

|
|
13
|
+

|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## π§© What This Actually Is
|
|
22
|
+
|
|
23
|
+
`Scyvera` provides a machine-readable specification and Python tooling layer for defining the operational boundary of intelligent or automated systems.
|
|
24
|
+
|
|
25
|
+
It is **NOT**:
|
|
26
|
+
- another agent framework
|
|
27
|
+
- an LLM wrapper
|
|
28
|
+
- an orchestration library
|
|
29
|
+
- a coding-agent framework
|
|
30
|
+
- a security sandbox or malware scanner
|
|
31
|
+
|
|
32
|
+
It **IS**:
|
|
33
|
+
A framework-independent and domain-independent specification layer describing system identity, capabilities, resources, inputs, outputs, permissions, constraints, side effects, approvals, dependencies, state persistence, failure recovery, replay semantics, observability, artifact trust declarations, and risk.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## π‘οΈ Validation vs. Runtime Enforcement
|
|
38
|
+
|
|
39
|
+
Scyvera provides two complementary governance layers:
|
|
40
|
+
|
|
41
|
+
| Layer | Component | Responsibility | Trust Level |
|
|
42
|
+
|---|---|---|---|
|
|
43
|
+
| **Tier 1 & 2: Static Verification** | `validate_contract()`, `lint_contract()` | Validates that a `contract.yaml` is structurally and semantically well-formed against specification schemas. | Declaration conformance |
|
|
44
|
+
| **Runtime Enforcement** | `ContractEnforcer` | Gates real-world Python calls against declared permissions and side effects using **Default-Deny** rules. Halts execution on approval points. | Execution boundary enforcement |
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## β‘ Quickstart
|
|
49
|
+
|
|
50
|
+
### 1. Installation
|
|
51
|
+
|
|
52
|
+
Install locally or in your project virtualenv:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install scyvera
|
|
56
|
+
# Or for local development:
|
|
57
|
+
pip install -e .
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 2. Command-Line Interface (CLI)
|
|
61
|
+
|
|
62
|
+
#### Create a starter Contract template (v1.1)
|
|
63
|
+
```bash
|
|
64
|
+
scyvera init contract.yaml --name "Research Assistant"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Interactive wizard mode:
|
|
68
|
+
```bash
|
|
69
|
+
scyvera init contract.yaml -i
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
#### Validate an Agent Contract
|
|
73
|
+
The CLI automatically detects the specification version (`1` vs `1.1`) and validates against the corresponding JSON Schema:
|
|
74
|
+
```bash
|
|
75
|
+
scyvera validate contract.yaml
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Output:
|
|
79
|
+
```text
|
|
80
|
+
PASS contract.yaml
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Override with a custom JSON Schema file:
|
|
84
|
+
```bash
|
|
85
|
+
scyvera validate contract.yaml --schema path/to/custom.schema.json
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## π Runtime Enforcer Quickstart
|
|
91
|
+
|
|
92
|
+
The `ContractEnforcer` protects your agent's execution boundaries in Python by enforcing **Default-Deny**: any undeclared permission or side effect raises `ContractViolationError`, and any action listed in `approval_points` raises `ApprovalPendingError`.
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from pathlib import Path
|
|
96
|
+
from scyvera import ContractEnforcer, ContractViolationError, ApprovalPendingError
|
|
97
|
+
|
|
98
|
+
# 1. Load, validate, and freeze the contract
|
|
99
|
+
enforcer = ContractEnforcer.load("implementations/n8n/duplicate-issue-detector/contract.yaml")
|
|
100
|
+
|
|
101
|
+
# 2. Gate sensitive tools and operations
|
|
102
|
+
@enforcer.gate(action_name="github: issues:write", action_type="permission")
|
|
103
|
+
def post_github_comment(issue_id: int, comment: str):
|
|
104
|
+
print(f"Posting comment to issue #{issue_id}: {comment}")
|
|
105
|
+
return True
|
|
106
|
+
|
|
107
|
+
@enforcer.gate(action_name="aws_s3:read", action_type="permission")
|
|
108
|
+
def read_s3_bucket():
|
|
109
|
+
return "s3_data"
|
|
110
|
+
|
|
111
|
+
# 3. Allowed calls execute cleanly and log to audit trail
|
|
112
|
+
post_github_comment(101, "Potential duplicate detected.")
|
|
113
|
+
|
|
114
|
+
# 4. Undeclared actions are denied immediately (Default-Deny)
|
|
115
|
+
try:
|
|
116
|
+
read_s3_bucket()
|
|
117
|
+
except ContractViolationError as e:
|
|
118
|
+
print(f"Blocked by Scyvera: {e}")
|
|
119
|
+
|
|
120
|
+
# 5. Inspect the immutable audit log
|
|
121
|
+
for entry in enforcer.get_audit_log():
|
|
122
|
+
print(f"[{entry.timestamp}] {entry.decision} - {entry.action_name} ({entry.reason})")
|
|
123
|
+
|
|
124
|
+
# 6. Verify file integrity on disk (Threat T5 defense)
|
|
125
|
+
enforcer.verify_integrity() # Raises ContractTamperError if contract.yaml was modified
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## β οΈ What Scyvera Does Not Guarantee
|
|
131
|
+
|
|
132
|
+
Scyvera provides structural verification and runtime gating, but security is an end-to-end discipline. Integrators must understand the following technical boundaries:
|
|
133
|
+
|
|
134
|
+
1. **Gate Bypass (Threat T4)**: Scyvera enforces boundaries at the `@enforcer.gate(...)` decorator. In Python, the runtime cannot physically prevent code from directly calling an un-decorated internal function. Integrators should use `ContractEnforcer.assert_gated(fn)` within their integration test suites to verify that all external-facing tool call sites are wrapped.
|
|
135
|
+
2. **Internal Third-Party Behavior / String Spoofing (Threat T6)**: Scyvera verifies that a declared intent (e.g. `github:issues:write`) matches an allowed permission in the contract. It does not perform dynamic bytecode analysis or network-packet inspection to guarantee that a decorated library function does not execute unauthorized background calls. The integrity of third-party dependencies remains the responsibility of dependency scanning and peer review.
|
|
136
|
+
3. **Pre-Load File Tampering (Threat T5)**: The SHA-256 integrity check in `verify_integrity()` protects against file replacement AFTER load. It does not protect against a tampered `contract.yaml` being present BEFORE `ContractEnforcer.load()` is called. The deployment environment is responsible for protecting the contract file prior to load.
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
You can programmatically construct, inspect, serialize, and validate Agent Contracts in Python without manually writing YAML:
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
from scyvera import Contract, validate_contract
|
|
144
|
+
|
|
145
|
+
# Programmatically construct a v1.1 Contract
|
|
146
|
+
contract = (
|
|
147
|
+
Contract(name="Literature Research Assistant", purpose="Analyzes scientific papers")
|
|
148
|
+
.set_domain("research")
|
|
149
|
+
.add_capability("search_documents", description="Queries research repositories")
|
|
150
|
+
.add_resource("paper_db", type="pdf_repository", access="read")
|
|
151
|
+
.add_input("research_topic", type="string", required=True)
|
|
152
|
+
.add_output("summary", type="document")
|
|
153
|
+
.add_permission("paper_db", actions=["read", "search"])
|
|
154
|
+
.set_state("session")
|
|
155
|
+
.set_recovery("retry")
|
|
156
|
+
.set_replay("idempotent")
|
|
157
|
+
.set_observability("basic")
|
|
158
|
+
.set_risk("low", category="misinformation_risk")
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
# Validate directly in code
|
|
162
|
+
result = contract.validate()
|
|
163
|
+
|
|
164
|
+
if result.valid:
|
|
165
|
+
print("Contract is valid!")
|
|
166
|
+
# Save to file
|
|
167
|
+
contract.save("contract.yaml")
|
|
168
|
+
else:
|
|
169
|
+
for err in result.errors:
|
|
170
|
+
print(f"Error at {err.path}: {err.message}")
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Validate an existing YAML file programmatically:
|
|
174
|
+
```python
|
|
175
|
+
from scyvera import validate_contract
|
|
176
|
+
|
|
177
|
+
result = validate_contract("contract.yaml")
|
|
178
|
+
print(f"Valid: {result.valid}")
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## π Every Implementation Documents a Contract
|
|
184
|
+
|
|
185
|
+
Instead of prose documentation alone, systems in this repository specify:
|
|
186
|
+
|
|
187
|
+
- **Identity & Purpose** β system identity, operational scope, and system version
|
|
188
|
+
- **Capabilities** β semantic ability claims
|
|
189
|
+
- **Resources** β data stores, APIs, entities, or systems accessed
|
|
190
|
+
- **Inputs & Outputs** β data entering and produced by the system
|
|
191
|
+
- **Permissions** β exact authorized `{resource, actions[]}` combinations
|
|
192
|
+
- **Constraints** β quantitative limits (e.g. rate limits, transaction caps)
|
|
193
|
+
- **Side Effects** β externally observable mutations
|
|
194
|
+
- **Approvals** β explicit human or expert approval gates
|
|
195
|
+
- **Dependencies** β required external services, models, APIs
|
|
196
|
+
- **State, Recovery, Replay, Observability** β persistence, failure strategy, idempotency, and audit evidence
|
|
197
|
+
- **Artifact Security & Risk** β model/data artifact trust requirements and risk level classification
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## π Repository Structure
|
|
202
|
+
|
|
203
|
+
```text
|
|
204
|
+
agent-contracts/
|
|
205
|
+
βββ README.md
|
|
206
|
+
βββ WORKFLOW-CONTRACT-SPEC.md
|
|
207
|
+
βββ CONTRIBUTING.md
|
|
208
|
+
βββ CONTRIBUTORS.md
|
|
209
|
+
βββ LICENSE
|
|
210
|
+
βββ pyproject.toml
|
|
211
|
+
βββ docs/
|
|
212
|
+
β βββ contract-model-v1.1.md # Normative v1.1 Specification
|
|
213
|
+
β βββ vision.md # Strategic Project Vision
|
|
214
|
+
β βββ design-principles.md # Normative Design Principles
|
|
215
|
+
β βββ terminology.md # Specification Terminology
|
|
216
|
+
βββ schemas/
|
|
217
|
+
β βββ v1/ # Contract v1 JSON Schema
|
|
218
|
+
β β βββ contract.schema.json
|
|
219
|
+
β βββ v1.1/ # Contract v1.1 JSON Schema
|
|
220
|
+
β βββ contract.schema.json
|
|
221
|
+
βββ examples/
|
|
222
|
+
β βββ v1.1/ # Domain-Neutral Examples (v1.1)
|
|
223
|
+
β βββ education-tutor.yaml
|
|
224
|
+
β βββ research-assistant.yaml
|
|
225
|
+
β βββ financial-operations.yaml
|
|
226
|
+
β βββ clinical-information-assistant.yaml
|
|
227
|
+
βββ src/
|
|
228
|
+
β βββ scyvera/ # Python Package
|
|
229
|
+
β βββ __init__.py
|
|
230
|
+
β βββ builder.py # Programmatic Contract Builder API
|
|
231
|
+
β βββ validator.py # Multi-Version Validator Engine
|
|
232
|
+
β βββ cli.py # CLI Application (validate, init)
|
|
233
|
+
β βββ schemas/ # Bundled Package Schemas
|
|
234
|
+
βββ tests/
|
|
235
|
+
β βββ fixtures/ # Test Fixture Files
|
|
236
|
+
β βββ test_validator.py # v1 Validator Unit Tests
|
|
237
|
+
β βββ test_validator_v1_1.py # v1.1 Validator Unit Tests
|
|
238
|
+
β βββ test_builder.py # Programmatic Builder Unit Tests
|
|
239
|
+
β βββ test_cli.py # CLI Unit Tests
|
|
240
|
+
βββ implementations/ # Multi-Framework Reference Implementations
|
|
241
|
+
βββ n8n/
|
|
242
|
+
βββ langgraph/
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## π Domain-Neutral Example Contracts (v1.1)
|
|
248
|
+
|
|
249
|
+
See [`examples/v1.1/`](./examples/v1.1) for runnable, validated v1.1 contracts across different domains:
|
|
250
|
+
|
|
251
|
+
| Domain | Contract File | Description |
|
|
252
|
+
|---|---|---|
|
|
253
|
+
| **Education** | [`education-tutor.yaml`](./examples/v1.1/education-tutor.yaml) | Guided study tutor, low risk, session state |
|
|
254
|
+
| **Research** | [`research-assistant.yaml`](./examples/v1.1/research-assistant.yaml) | Scientific literature analysis, arXiv API dependency |
|
|
255
|
+
| **Finance** | [`financial-operations.yaml`](./examples/v1.1/financial-operations.yaml) | Critical risk, payment caps ($5000 USD limit), controller approval gate |
|
|
256
|
+
| **Healthcare** | [`clinical-information-assistant.yaml`](./examples/v1.1/clinical-information-assistant.yaml) | High risk, EHR database access, physician approval gate, model integrity requirements |
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## π Security & Governance Boundary Notice
|
|
261
|
+
|
|
262
|
+
> [!IMPORTANT]
|
|
263
|
+
> **Contract Declaration β Security Verification β Runtime Enforcement.**
|
|
264
|
+
> An Agent Contract describes declared operational boundaries. It is not a sandbox, anti-malware scanner, or runtime enforcement proxy. Contract declarations provide structured input upon which external policy engines, verification scanners, and runtime isolation systems operate.
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## πΊοΈ Where the Spec Is Headed (v1.1)
|
|
269
|
+
|
|
270
|
+
Contract v1 was designed and proven against coding/developer agents. That's now understood to be a starting substrate, not the ceiling β v1.1 is a deliberate audit-and-redesign effort to make the spec:
|
|
271
|
+
|
|
272
|
+
- **Domain-independent** β usable for research, education, finance, business-workflow, and healthcare-workflow agents, not just coding agents
|
|
273
|
+
- **Framework-independent** β already true in principle (n8n + LangGraph prove it), being stress-tested further
|
|
274
|
+
- **Accessible to non-technical authors** β YAML/JSON is a representation format, not meant to be the only way to create a contract
|
|
275
|
+
|
|
276
|
+
This is genuinely in the design/audit phase β classifying existing Contract v1 fields, testing them against non-coding agent archetypes, and only then extending the schema. Nothing in this section describes a shipped feature. Follow progress in [`implementations/rfcs/`](./implementations/rfcs) and open issues tagged `v1.1`.
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## π€ Contributing
|
|
281
|
+
|
|
282
|
+
Contributions are welcome β new domain profiles, framework reference implementations, specification RFCs, or Python API improvements. See [CONTRIBUTING.md](./CONTRIBUTING.md) for details.
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## π License
|
|
287
|
+
|
|
288
|
+
Distributed under the MIT License β see [LICENSE](./LICENSE) for details.
|
|
289
|
+
|
|
290
|
+
Built and maintained by [Shinjan Das](https://github.com/Skull-boy) and open-source contributors β see [CONTRIBUTORS.md](./CONTRIBUTORS.md).
|