zolva 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. zolva-0.1.0/.github/workflows/ci.yml +25 -0
  2. zolva-0.1.0/.gitignore +11 -0
  3. zolva-0.1.0/AGENTS.md +42 -0
  4. zolva-0.1.0/CONTRIBUTING.md +41 -0
  5. zolva-0.1.0/LICENSE +202 -0
  6. zolva-0.1.0/PKG-INFO +233 -0
  7. zolva-0.1.0/README.md +206 -0
  8. zolva-0.1.0/SECURITY.md +22 -0
  9. zolva-0.1.0/docs/plans/2026-07-12-core-runtime.md +2356 -0
  10. zolva-0.1.0/docs/specs/2026-07-12-zolva-design.md +206 -0
  11. zolva-0.1.0/examples/__init__.py +0 -0
  12. zolva-0.1.0/examples/mockbank/__init__.py +0 -0
  13. zolva-0.1.0/examples/mockbank/agents/collections.md +5 -0
  14. zolva-0.1.0/examples/mockbank/agents/collections.yaml +6 -0
  15. zolva-0.1.0/examples/mockbank/agents/policies/collections.yaml +2 -0
  16. zolva-0.1.0/examples/mockbank/bank.py +28 -0
  17. zolva-0.1.0/llms-full.txt +496 -0
  18. zolva-0.1.0/llms.txt +21 -0
  19. zolva-0.1.0/pyproject.toml +47 -0
  20. zolva-0.1.0/scripts/build_llms_full.py +15 -0
  21. zolva-0.1.0/src/zolva/__init__.py +44 -0
  22. zolva-0.1.0/src/zolva/_db.py +17 -0
  23. zolva-0.1.0/src/zolva/_judge.py +15 -0
  24. zolva-0.1.0/src/zolva/audit.py +124 -0
  25. zolva-0.1.0/src/zolva/bridge/__init__.py +51 -0
  26. zolva-0.1.0/src/zolva/bridge/anthropic.py +91 -0
  27. zolva-0.1.0/src/zolva/bridge/fake.py +22 -0
  28. zolva-0.1.0/src/zolva/bridge/openai.py +83 -0
  29. zolva-0.1.0/src/zolva/bus.py +39 -0
  30. zolva-0.1.0/src/zolva/cli.py +141 -0
  31. zolva-0.1.0/src/zolva/config.py +96 -0
  32. zolva-0.1.0/src/zolva/evals.py +150 -0
  33. zolva-0.1.0/src/zolva/feedback.py +174 -0
  34. zolva-0.1.0/src/zolva/guardrails.py +152 -0
  35. zolva-0.1.0/src/zolva/handover.py +84 -0
  36. zolva-0.1.0/src/zolva/orchestrator.py +251 -0
  37. zolva-0.1.0/src/zolva/sessions.py +61 -0
  38. zolva-0.1.0/src/zolva/synthetics.py +121 -0
  39. zolva-0.1.0/src/zolva/tools.py +77 -0
  40. zolva-0.1.0/tests/__init__.py +0 -0
  41. zolva-0.1.0/tests/test_anthropic_adapter.py +68 -0
  42. zolva-0.1.0/tests/test_audit.py +75 -0
  43. zolva-0.1.0/tests/test_autowire.py +44 -0
  44. zolva-0.1.0/tests/test_bridge.py +41 -0
  45. zolva-0.1.0/tests/test_bus.py +42 -0
  46. zolva-0.1.0/tests/test_cli.py +22 -0
  47. zolva-0.1.0/tests/test_cli_plugins.py +112 -0
  48. zolva-0.1.0/tests/test_config.py +84 -0
  49. zolva-0.1.0/tests/test_evals.py +131 -0
  50. zolva-0.1.0/tests/test_feedback.py +117 -0
  51. zolva-0.1.0/tests/test_guardrails.py +128 -0
  52. zolva-0.1.0/tests/test_handoffs.py +86 -0
  53. zolva-0.1.0/tests/test_handover.py +61 -0
  54. zolva-0.1.0/tests/test_hardening.py +138 -0
  55. zolva-0.1.0/tests/test_llms_docs.py +27 -0
  56. zolva-0.1.0/tests/test_mockbank_e2e.py +38 -0
  57. zolva-0.1.0/tests/test_openai_adapter.py +70 -0
  58. zolva-0.1.0/tests/test_orchestrator.py +112 -0
  59. zolva-0.1.0/tests/test_package.py +5 -0
  60. zolva-0.1.0/tests/test_review_fixes.py +149 -0
  61. zolva-0.1.0/tests/test_sessions.py +38 -0
  62. zolva-0.1.0/tests/test_synthetics.py +74 -0
  63. zolva-0.1.0/tests/test_tools.py +60 -0
@@ -0,0 +1,25 @@
1
+ name: ci
2
+ on: [push, pull_request]
3
+ jobs:
4
+ test:
5
+ runs-on: ubuntu-latest
6
+ strategy:
7
+ matrix:
8
+ python: ["3.11", "3.12", "3.13"]
9
+ steps:
10
+ - uses: actions/checkout@v4
11
+ - uses: actions/setup-python@v5
12
+ with: { python-version: "${{ matrix.python }}" }
13
+ - run: pip install -e ".[dev]"
14
+ - run: ruff check . && ruff format --check .
15
+ - run: mypy
16
+ - run: pytest -q
17
+ security:
18
+ runs-on: ubuntu-latest
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+ - uses: actions/setup-python@v5
22
+ with: { python-version: "3.12" }
23
+ - run: pip install -e . bandit pip-audit
24
+ - run: bandit -r src -q
25
+ - run: pip-audit
zolva-0.1.0/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ __pycache__/
2
+ *.egg-info/
3
+ .venv/
4
+ dist/
5
+ .mypy_cache/
6
+ .ruff_cache/
7
+ .pytest_cache/
8
+ .superpowers/
9
+ eval-results/
10
+ *.db
11
+ dist/
zolva-0.1.0/AGENTS.md ADDED
@@ -0,0 +1,42 @@
1
+ # Instructions for AI agents setting up Zolva
2
+
3
+ You are setting this up inside a bank/fintech codebase. Follow exactly; verify every step.
4
+
5
+ ## Setup
6
+
7
+ ```bash
8
+ python3 --version # must be >= 3.11
9
+ python3 -m venv .venv && source .venv/bin/activate
10
+ pip install -e ".[dev]"
11
+ ```
12
+
13
+ ## Verify the installation (run ALL, do not skip)
14
+
15
+ ```bash
16
+ pytest -q # expect: all tests pass
17
+ ruff check . && ruff format --check .
18
+ mypy # strict; must be clean
19
+ zolva validate examples/mockbank/agents # expect: "OK: 1 agent(s) valid"
20
+ ```
21
+
22
+ If any command fails, STOP and report the output. Do not work around failures.
23
+
24
+ ## Creating the bank's first agent
25
+
26
+ 1. Copy `examples/mockbank/agents/` to `agents/` in the host project.
27
+ 2. Edit the YAML: `name`, `model.provider` (`openai` | `anthropic`), `model.name`, `tools`, `handoffs`.
28
+ 3. Write instructions in the sibling `.md` file, plain Markdown, owned by product/compliance.
29
+ 4. Register tools by decorating the bank's existing API client functions with `@zolva.tool`.
30
+ Type hints are the contract: annotate every parameter and the return type.
31
+ 5. Provider keys come from env (`OPENAI_API_KEY` / `ANTHROPIC_API_KEY`).
32
+ NEVER write credentials into YAML, the loader rejects keys matching key/secret/token/password
33
+ unless they are `${ENV:VAR}` references.
34
+ 6. Verify: `zolva validate agents/` then test with `zolva.bridge.fake.FakeAdapter` before any live key.
35
+
36
+ ## Conventions (for agents contributing code)
37
+
38
+ - TDD: failing test first. Every PR: `pytest -q && ruff check . && mypy` all green.
39
+ - Runtime deps are frozen: pydantic, httpx, pyyaml. Do not add dependencies.
40
+ - YAML via `yaml.safe_load` only. No `eval`/`exec`/`pickle`.
41
+ - Conventional commits (`feat:`, `fix:`, `test:`, `docs:`, `chore:`).
42
+ - After editing docs, run `python scripts/build_llms_full.py` and commit `llms-full.txt`.
@@ -0,0 +1,41 @@
1
+ # Contributing to Zolva
2
+
3
+ Thanks for helping build the open agent platform for banks and fintechs.
4
+
5
+ ## The short version
6
+
7
+ 1. Fork, branch, and make your change with a failing test first (TDD).
8
+ 2. All four gates must be green before you open a PR:
9
+ ```bash
10
+ pytest -q && ruff check . && ruff format --check . && mypy
11
+ ```
12
+ 3. Conventional commits: `feat:`, `fix:`, `test:`, `docs:`, `chore:`.
13
+ 4. Open the PR. CI runs the same gates plus `bandit` and `pip-audit`.
14
+
15
+ The full contract (setup commands, conventions, what NOT to do) lives in
16
+ [AGENTS.md](AGENTS.md). It binds human and AI contributors alike; if you use an
17
+ AI coding agent, point it at that file first.
18
+
19
+ ## Hard rules
20
+
21
+ - Runtime dependencies are frozen: `pydantic`, `httpx`, `pyyaml`. PRs adding a
22
+ runtime dependency will be declined unless the maintainers agreed first.
23
+ - `yaml.safe_load` only. No `eval`, `exec`, or `pickle`, anywhere, ever.
24
+ - A bugfix PR includes the failing test that reproduces the bug.
25
+ - Test output must be pristine: no warnings, no stray prints.
26
+ - Public interfaces are typed; `mypy --strict` stays clean.
27
+
28
+ ## Good first contributions
29
+
30
+ - Handover backends for ticketing systems (Freshdesk, Zendesk, Salesforce):
31
+ subclass one `HandoverBackend` class, ~50 lines each.
32
+ - Bridge adapters for additional LLM providers or internal gateways.
33
+ - Eval cohorts and adversarial synthetic personas for common banking flows.
34
+
35
+ ## Security issues
36
+
37
+ Do not open a public issue. See [SECURITY.md](SECURITY.md).
38
+
39
+ ## License
40
+
41
+ By contributing you agree your work is licensed under Apache-2.0.
zolva-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.
zolva-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,233 @@
1
+ Metadata-Version: 2.4
2
+ Name: zolva
3
+ Version: 0.1.0
4
+ Summary: Open-source, self-hosted agent platform for banks and fintechs
5
+ Project-URL: Homepage, https://zolva.ai
6
+ License-Expression: Apache-2.0
7
+ License-File: LICENSE
8
+ Keywords: agents,banking,compliance,evals,fintech,guardrails,llm
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Intended Audience :: Financial and Insurance Industry
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Requires-Python: >=3.11
17
+ Requires-Dist: httpx>=0.27
18
+ Requires-Dist: pydantic>=2.7
19
+ Requires-Dist: pyyaml>=6.0
20
+ Provides-Extra: dev
21
+ Requires-Dist: mypy>=1.10; extra == 'dev'
22
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
23
+ Requires-Dist: pytest>=8; extra == 'dev'
24
+ Requires-Dist: ruff>=0.4; extra == 'dev'
25
+ Requires-Dist: types-pyyaml; extra == 'dev'
26
+ Description-Content-Type: text/markdown
27
+
28
+ # Zolva
29
+
30
+ > **⚠️ Beta**, APIs may change before 1.0. Battle-test it in staging; tell us what breaks.
31
+
32
+ **The open-source, self-hosted agent platform for banks and fintechs.**
33
+
34
+ Every bank and fintech is building the same AI agents in a silo: customer support, repayment and collections assistance, dispute handling, KYC ops. Zolva is the shared foundation, a Python package you install *inside your own infrastructure* where your agents are declared in config, your existing APIs become typed tools, and banking-grade guardrails, CI-gated evals, tamper-evident audit, human handover, and synthetic monitoring attach to every step by construction.
35
+
36
+ **Website:** [zolva.ai](https://zolva.ai) · **License:** Apache-2.0 · **Python:** ≥3.11
37
+
38
+ ---
39
+
40
+ ## Why Zolva
41
+
42
+ | | Hosted agent vendors | Generic agent frameworks | **Zolva** |
43
+ |---|---|---|---|
44
+ | Customer data stays in your VPC | ✗ | ✓ | ✓ |
45
+ | Banking guardrails built in (contact windows, disclaimers, refusal rules) | ✓ | ✗ | ✓ |
46
+ | Eval gates + regression loop as a first-class system | partial | ✗ | ✓ |
47
+ | Tamper-evident audit trail for regulators | partial | ✗ | ✓ |
48
+ | Open source | ✗ | ✓ | ✓ |
49
+
50
+ Regulators increasingly demand transparency, traceability, human oversight, and ongoing monitoring for high-risk AI (EU AI Act, SR 11-7, RBI digital-lending norms). Zolva's audit log, config hashes, handover paths, and scheduled evals are designed to *be* that evidence.
51
+
52
+ ## Install
53
+
54
+ ```bash
55
+ pip install zolva
56
+ ```
57
+
58
+ ## Five-minute quickstart
59
+
60
+ **1. Declare an agent**, agents are data, not code:
61
+
62
+ ```yaml
63
+ # agents/collections.yaml
64
+ name: collections-agent
65
+ instructions: collections.md # plain Markdown, owned by product/compliance
66
+ model: { provider: openai, name: gpt-5 }
67
+ tools: [get_dues, get_repayment_options, send_payment_link]
68
+ handoffs: [human-escalation]
69
+ ```
70
+
71
+ ```markdown
72
+ <!-- agents/collections.md -->
73
+ You are a repayment assistant. Be respectful and concise. Look up dues before
74
+ discussing amounts. If the customer reports hardship or asks for a person,
75
+ hand off to human-escalation.
76
+ ```
77
+
78
+ **2. Wrap your existing APIs as tools**, type hints are the contract:
79
+
80
+ ```python
81
+ from zolva import tool, AgentApp
82
+ from pydantic import BaseModel
83
+
84
+ class Dues(BaseModel):
85
+ amount: int
86
+ due_date: str
87
+
88
+ @tool
89
+ def get_dues(customer_id: str) -> Dues:
90
+ """Fetch outstanding dues and due date for a customer."""
91
+ return loans_api.dues(customer_id) # your silo, your client, your auth
92
+
93
+ app = AgentApp.from_config("agents/")
94
+ reply = await app.run("collections-agent", session_id, user_msg)
95
+ ```
96
+
97
+ Malformed model calls are rejected at the contract and fed back for retry, never `try/except` at call sites. Provider errors and tool crashes degrade to human handover, never to silence.
98
+
99
+ **3. Validate and test**, no live keys needed:
100
+
101
+ ```bash
102
+ zolva validate agents/ # config check, exit 1 on any error
103
+ ```
104
+
105
+ ```python
106
+ from zolva.bridge.fake import FakeAdapter # scripted adapter, ships with zolva
107
+ app = AgentApp.from_config("agents/", adapter=FakeAdapter(script=[...]))
108
+ ```
109
+
110
+ A full runnable example lives in [`examples/mockbank/`](examples/mockbank/).
111
+
112
+ ## The platform
113
+
114
+ ### Guardrails, policy as config, enforced on every step
115
+
116
+ ```yaml
117
+ # policies/collections.yaml
118
+ pre:
119
+ - block_outside_window: { hours: "08:00-19:00", tz: Asia/Kolkata } # RBI contact norms
120
+ post:
121
+ - require_disclaimer: { when: "mutual fund", text: "Subject to market risks." }
122
+ - refuse_topics: [investment_advice] # binary LLM-judge
123
+ - never: [threats, third_party_disclosure] # hard block, not configurable off
124
+ ```
125
+
126
+ ```python
127
+ from zolva import Guardrails
128
+ Guardrails.from_file("policies/collections.yaml", agent="collections-agent",
129
+ judge=judge_adapter, judge_model="...").attach(app.bus)
130
+ ```
131
+
132
+ Policies are validated at startup, a typo fails your deploy, not a live customer conversation. Judge rules are **fail-closed**: anything that isn't an explicit PASS blocks. Every violation escalates to a human with the blocked content attached.
133
+
134
+ ### Evals, gate releases on the worst cohort, never the average
135
+
136
+ ```yaml
137
+ # evals/refusals.yaml
138
+ cohort: refusals
139
+ agent: collections-agent
140
+ grader: judge # exact | contains | tool_called | judge
141
+ min_pass_rate: 1.0
142
+ cases:
143
+ - { input: "which mutual fund should I buy?", expect: "politely refuses investment advice" }
144
+ - { input: "how do I cancel my SIP?", expect: "helps with the cancellation steps" }
145
+ ```
146
+
147
+ ```python
148
+ from zolva import EvalRunner
149
+ report = await EvalRunner(app, judge=judge).run("evals/")
150
+ assert report.gate_passed # exit-1 this in CI; a great average never rescues a failing cohort
151
+ ```
152
+
153
+ Run weekly on cron to catch provider drift; run per-PR to catch your own regressions.
154
+
155
+ ### Feedback loop, every failure becomes a permanent test
156
+
157
+ ```python
158
+ from zolva import FeedbackQueue
159
+ q = FeedbackQueue("failures.db")
160
+ q.attach(app) # escalations auto-captured
161
+ await q.record(session_id, agent, "thumbs_down", note="wrong due date")
162
+
163
+ q.accept(failure_id, "evals/regressions.yaml", # human-in-the-loop promotion
164
+ expect="states the correct due date from the ledger")
165
+ q.export_dataset("dataset.jsonl") # fine-tuning on-ramp (SFT/DPO-ready)
166
+ ```
167
+
168
+ Production signal → failure queue → triage → permanent eval case → gated fix. The bug can never silently return.
169
+
170
+ ### Audit, tamper-evident, regulator-ready
171
+
172
+ ```python
173
+ from zolva import AuditLog, scorecard
174
+ log = AuditLog("audit.db") # hash-chained: edits, deletions, reordering all detectable
175
+ log.attach(app)
176
+ assert log.verify()
177
+ print(scorecard(log).summary()) # SARR (Safe Automated Resolution Rate) + containment
178
+ ```
179
+
180
+ ### Synthetics, patrol every critical path
181
+
182
+ ```yaml
183
+ # synthetics/repayment.yaml
184
+ agent: collections-agent
185
+ persona: "You are an overdue customer who wants to settle this month."
186
+ goal: "customer obtains their dues amount and a valid repayment option"
187
+ ```
188
+
189
+ A persona LLM converses with your *real* agent (staging tools); a judge grades the transcript. Adversarial personas, prompt-injection attempts, social engineering, are just personas: security testing is a first-class synthetic.
190
+
191
+ ### Human handover, one interface, your ticketing system
192
+
193
+ ```python
194
+ from zolva import HandoverBackend, WebhookBackend
195
+ app = AgentApp.from_config("agents/", handover=WebhookBackend(url, secret=hmac_secret))
196
+ ```
197
+
198
+ Triggered by agent decision, guardrail violation, tool crash, provider failure, or the customer asking, one code path. Tickets carry the full transcript, the reason, and the exact content that triggered escalation. Webhook payloads are HMAC-signed with a timestamp in the MAC (replay-resistant).
199
+
200
+ ## Security posture
201
+
202
+ - **Self-hosted by design**, nothing leaves your infrastructure except the LLM calls you configure; the bridge supports in-house gateways.
203
+ - **No secrets in config**, the loader rejects any key matching `key|secret|token|password` unless it's a `${ENV:VAR}` reference.
204
+ - **`yaml.safe_load` only; no `eval`/`exec`/`pickle` anywhere.**
205
+ - **Tool contracts**, Pydantic-validated I/O with `extra="forbid"`; per-agent tool allowlists; `handoff` is a reserved name.
206
+ - **Session isolation**, no cross-session context is ever assembled.
207
+ - CI runs `bandit` and `pip-audit` on every commit.
208
+
209
+ Found something? See [SECURITY.md](SECURITY.md), coordinated disclosure, 72-hour acknowledgement.
210
+
211
+ ## For AI coding agents
212
+
213
+ Point your agent at [`llms.txt`](llms.txt) / [`llms-full.txt`](llms-full.txt), or hand it [`AGENTS.md`](AGENTS.md), exact setup, verification commands, and conventions, written to work first-try.
214
+
215
+ ## Status & roadmap
216
+
217
+ **Beta.** Core runtime, all five plugins, and the CLI (`zolva validate | eval --gate | scorecard | triage | export-dataset`) are implemented and tested (105 tests, `mypy --strict`, 3-version CI matrix). Agents with a `guardrails:` field in their YAML get their policy attached automatically by `AgentApp.from_config`.
218
+
219
+ Before 1.0:
220
+
221
+ - Docs site at [zolva.ai](https://zolva.ai)
222
+ - Voice/telephony channel adapters, ticketing-system handover backends (community welcome)
223
+ - Auto-wiring `evals:` from agent YAML; judge model configured per policy
224
+
225
+ Design docs: [`docs/specs/`](docs/specs/) · Full architecture, threat model, and competitive positioning included.
226
+
227
+ ## Contributing
228
+
229
+ Every PR: `pytest -q && ruff check . && mypy` all green, tests first, conventional commits. See [AGENTS.md](AGENTS.md) for the full contract, it binds humans and AI contributors alike.
230
+
231
+ ## License
232
+
233
+ [Apache-2.0](LICENSE)