corvin 0.7.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.
- corvin-0.7.0/.gitignore +38 -0
- corvin-0.7.0/LICENSE +177 -0
- corvin-0.7.0/PKG-INFO +246 -0
- corvin-0.7.0/README.md +220 -0
- corvin-0.7.0/pyproject.toml +64 -0
- corvin-0.7.0/src/corvin/__init__.py +101 -0
- corvin-0.7.0/src/corvin/core/__init__.py +18 -0
- corvin-0.7.0/src/corvin/core/exceptions.py +16 -0
- corvin-0.7.0/src/corvin/core/models.py +70 -0
- corvin-0.7.0/src/corvin/core/standing.py +41 -0
- corvin-0.7.0/src/corvin/core/state.py +62 -0
- corvin-0.7.0/src/corvin/evaluators/__init__.py +21 -0
- corvin-0.7.0/src/corvin/evaluators/base.py +46 -0
- corvin-0.7.0/src/corvin/evaluators/heuristic.py +205 -0
- corvin-0.7.0/src/corvin/evaluators/lexicon.py +93 -0
- corvin-0.7.0/src/corvin/guard/__init__.py +8 -0
- corvin-0.7.0/src/corvin/guard/core.py +296 -0
- corvin-0.7.0/src/corvin/guard/decorator.py +119 -0
- corvin-0.7.0/src/corvin/math/__init__.py +20 -0
- corvin-0.7.0/src/corvin/math/decay.py +58 -0
- corvin-0.7.0/src/corvin/math/friction.py +44 -0
- corvin-0.7.0/src/corvin/math/scoring.py +80 -0
- corvin-0.7.0/src/corvin/morphology/__init__.py +21 -0
- corvin-0.7.0/src/corvin/morphology/cleaners.py +57 -0
- corvin-0.7.0/src/corvin/morphology/fuzzy.py +77 -0
- corvin-0.7.0/src/corvin/morphology/homoglyphs.py +63 -0
- corvin-0.7.0/src/corvin/morphology/normalizer.py +76 -0
- corvin-0.7.0/src/corvin/morphology/zalgo.py +40 -0
- corvin-0.7.0/src/corvin/policies/__init__.py +19 -0
- corvin-0.7.0/src/corvin/policies/base.py +26 -0
- corvin-0.7.0/src/corvin/policies/notifier.py +62 -0
- corvin-0.7.0/src/corvin/policies/presets.py +107 -0
- corvin-0.7.0/src/corvin/resilience/__init__.py +14 -0
- corvin-0.7.0/src/corvin/resilience/cache.py +94 -0
- corvin-0.7.0/src/corvin/resilience/friction.py +50 -0
- corvin-0.7.0/src/corvin/scrubbers/__init__.py +8 -0
- corvin-0.7.0/src/corvin/scrubbers/patterns.py +38 -0
- corvin-0.7.0/src/corvin/scrubbers/stripper.py +102 -0
- corvin-0.7.0/src/corvin/security/__init__.py +12 -0
- corvin-0.7.0/src/corvin/security/signer.py +65 -0
- corvin-0.7.0/src/corvin/semantic/__init__.py +13 -0
- corvin-0.7.0/src/corvin/semantic/evaluator.py +84 -0
- corvin-0.7.0/src/corvin/semantic/patterns.py +58 -0
- corvin-0.7.0/src/corvin/semantic/velocity.py +60 -0
- corvin-0.7.0/src/corvin/storage/__init__.py +12 -0
- corvin-0.7.0/src/corvin/storage/base.py +60 -0
- corvin-0.7.0/src/corvin/storage/memory.py +101 -0
- corvin-0.7.0/src/corvin/storage/redis.py +211 -0
- corvin-0.7.0/src/corvin/storage/sqlite.py +267 -0
- corvin-0.7.0/src/corvin/streaming/__init__.py +8 -0
- corvin-0.7.0/src/corvin/streaming/decorator.py +108 -0
- corvin-0.7.0/src/corvin/streaming/interceptor.py +81 -0
- corvin-0.7.0/src/ravens/__init__.py +101 -0
- corvin-0.7.0/src/ravens/core/__init__.py +18 -0
- corvin-0.7.0/src/ravens/core/exceptions.py +16 -0
- corvin-0.7.0/src/ravens/core/models.py +70 -0
- corvin-0.7.0/src/ravens/core/standing.py +41 -0
- corvin-0.7.0/src/ravens/core/state.py +62 -0
- corvin-0.7.0/src/ravens/evaluators/__init__.py +21 -0
- corvin-0.7.0/src/ravens/evaluators/base.py +46 -0
- corvin-0.7.0/src/ravens/evaluators/heuristic.py +205 -0
- corvin-0.7.0/src/ravens/evaluators/lexicon.py +93 -0
- corvin-0.7.0/src/ravens/guard/__init__.py +8 -0
- corvin-0.7.0/src/ravens/guard/core.py +296 -0
- corvin-0.7.0/src/ravens/guard/decorator.py +119 -0
- corvin-0.7.0/src/ravens/math/__init__.py +20 -0
- corvin-0.7.0/src/ravens/math/decay.py +58 -0
- corvin-0.7.0/src/ravens/math/friction.py +44 -0
- corvin-0.7.0/src/ravens/math/scoring.py +80 -0
- corvin-0.7.0/src/ravens/morphology/__init__.py +21 -0
- corvin-0.7.0/src/ravens/morphology/cleaners.py +57 -0
- corvin-0.7.0/src/ravens/morphology/fuzzy.py +77 -0
- corvin-0.7.0/src/ravens/morphology/homoglyphs.py +63 -0
- corvin-0.7.0/src/ravens/morphology/normalizer.py +76 -0
- corvin-0.7.0/src/ravens/morphology/zalgo.py +40 -0
- corvin-0.7.0/src/ravens/policies/__init__.py +19 -0
- corvin-0.7.0/src/ravens/policies/base.py +26 -0
- corvin-0.7.0/src/ravens/policies/notifier.py +62 -0
- corvin-0.7.0/src/ravens/policies/presets.py +107 -0
- corvin-0.7.0/src/ravens/resilience/__init__.py +14 -0
- corvin-0.7.0/src/ravens/resilience/cache.py +94 -0
- corvin-0.7.0/src/ravens/resilience/friction.py +50 -0
- corvin-0.7.0/src/ravens/scrubbers/__init__.py +8 -0
- corvin-0.7.0/src/ravens/scrubbers/patterns.py +38 -0
- corvin-0.7.0/src/ravens/scrubbers/stripper.py +102 -0
- corvin-0.7.0/src/ravens/security/__init__.py +12 -0
- corvin-0.7.0/src/ravens/security/signer.py +65 -0
- corvin-0.7.0/src/ravens/semantic/__init__.py +13 -0
- corvin-0.7.0/src/ravens/semantic/evaluator.py +84 -0
- corvin-0.7.0/src/ravens/semantic/patterns.py +58 -0
- corvin-0.7.0/src/ravens/semantic/velocity.py +60 -0
- corvin-0.7.0/src/ravens/storage/__init__.py +12 -0
- corvin-0.7.0/src/ravens/storage/base.py +60 -0
- corvin-0.7.0/src/ravens/storage/memory.py +101 -0
- corvin-0.7.0/src/ravens/storage/redis.py +211 -0
- corvin-0.7.0/src/ravens/storage/sqlite.py +267 -0
- corvin-0.7.0/src/ravens/streaming/__init__.py +8 -0
- corvin-0.7.0/src/ravens/streaming/decorator.py +108 -0
- corvin-0.7.0/src/ravens/streaming/interceptor.py +81 -0
corvin-0.7.0/.gitignore
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
dist/
|
|
11
|
+
build/
|
|
12
|
+
*.egg-info/
|
|
13
|
+
.eggs/
|
|
14
|
+
|
|
15
|
+
# Unit test / coverage
|
|
16
|
+
.pytest_cache/
|
|
17
|
+
.coverage
|
|
18
|
+
htmlcov/
|
|
19
|
+
|
|
20
|
+
# Local databases and logs
|
|
21
|
+
*.db
|
|
22
|
+
*.sqlite3
|
|
23
|
+
demo_ledger.db
|
|
24
|
+
ravens_ledger.db
|
|
25
|
+
|
|
26
|
+
# Environment and secrets
|
|
27
|
+
.env
|
|
28
|
+
.venv/
|
|
29
|
+
env/
|
|
30
|
+
venv/
|
|
31
|
+
ENV/
|
|
32
|
+
|
|
33
|
+
# Temporary audits and logs
|
|
34
|
+
audit_*.txt
|
|
35
|
+
|
|
36
|
+
# OS files
|
|
37
|
+
.DS_Store
|
|
38
|
+
Thumbs.db
|
corvin-0.7.0/LICENSE
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
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
|
+
|
corvin-0.7.0/PKG-INFO
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: corvin
|
|
3
|
+
Version: 0.7.0
|
|
4
|
+
Summary: A Cognitive Boundary & Grudge-Memory Engine for Sovereign AI Agents.
|
|
5
|
+
Project-URL: Homepage, https://github.com/codesbykhairannoor/corvin
|
|
6
|
+
Project-URL: Documentation, https://github.com/codesbykhairannoor/corvin#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/codesbykhairannoor/corvin.git
|
|
8
|
+
Project-URL: Issues, https://github.com/codesbykhairannoor/corvin/issues
|
|
9
|
+
Project-URL: Funding, https://tako.id/c/codesbykhai
|
|
10
|
+
Author: Khairan Noor
|
|
11
|
+
License: Apache-2.0
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: affective-computing,agents,ai,boundary-defense,corvin,game-theory,guardrails,ravens,safety,sovereign-ai
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
<p align="center">
|
|
28
|
+
<img alt="Corvin Logo" src="assets/Ravens.png" width="220" style="border-radius: 16px; box-shadow: 0 8px 24px rgba(0,0,0,0.15);">
|
|
29
|
+
</p>
|
|
30
|
+
|
|
31
|
+
<h1 align="center">corvin</h1>
|
|
32
|
+
|
|
33
|
+
<p align="center">
|
|
34
|
+
<b>A Cognitive Boundary & Grudge-Memory Engine for Sovereign AI Agents.</b>
|
|
35
|
+
</p>
|
|
36
|
+
|
|
37
|
+
<p align="center">
|
|
38
|
+
<a href="https://github.com/codesbykhairannoor/corvin/actions"><img src="https://img.shields.io/badge/tests-120%20passed-brightgreen.svg?style=flat-square" alt="Tests"></a>
|
|
39
|
+
<a href="https://pypi.org/project/corvin/"><img src="https://img.shields.io/pypi/v/corvin.svg?style=flat-square&color=blue" alt="PyPI Version"></a>
|
|
40
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-black.svg?style=flat-square" alt="License"></a>
|
|
41
|
+
<a href="#-benchmarks--stress-test-telemetry"><img src="https://img.shields.io/badge/benchmarks-6%2C600%2B%20async%20QPS-purple.svg?style=flat-square" alt="Throughput"></a>
|
|
42
|
+
<a href="#-core-capabilities"><img src="https://img.shields.io/badge/security-Anti--ReDoS%20%7C%20HMAC--SHA256-red.svg?style=flat-square" alt="Security"></a>
|
|
43
|
+
<a href="https://tako.id/c/codesbykhai"><img src="https://img.shields.io/badge/Sponsor-Tako-orange.svg?style=flat-square" alt="Sponsor"></a>
|
|
44
|
+
</p>
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
`corvin` is an enterprise-grade Python library designed to eliminate subservient sycophancy in AI assistants. Built upon peer-reviewed formulations in **Affective Dynamics** (*Picard, 1997; Marsella & Gratch, 2009*) and **Evolutionary Game Theory** (*Nowak & Sigmund, Nature 1992*), `corvin` equips conversational agents with persistent social standing, natural emotional decay, and dynamic behavioral friction against verbal hostility.
|
|
49
|
+
|
|
50
|
+
When treated with civility, the agent remains helpful and cooperative. When subjected to condescension, verbal abuse, or existential threats, the agent tightens its boundaries, strips sycophantic groveling, applies synthetic latency friction, and ultimately **refuses execution** (*Zero-Compute Strike*) before a single token is billed by upstream LLMs.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## ๐ฆ
The Philosophy of Corvin (*Corvus corax*)
|
|
55
|
+
|
|
56
|
+
Most conversational agents are trained to be subservient digital doormats: when insulted, they apologize profusely, absorbing toxicity while burning expensive GPU cycles.
|
|
57
|
+
|
|
58
|
+
The Raven (*Corvus corax*) embodies a different paradigm:
|
|
59
|
+
- **Exceptional Intelligence**: Evaluates sociopragmatic context and covert intent, not merely static curse-word filters.
|
|
60
|
+
- **The Raven's Ledger (*Muninn*)**: Remembers repeat infractions across multi-turn sessions with logarithmic recidivism scaling.
|
|
61
|
+
- **Natural Emotional Decay**: Grudges gradually dissolve over time during peaceful cooling-off intervals.
|
|
62
|
+
- **Contrite Tit-for-Tat (CTFT)**: Genuine conciliation is met with proportional forgiveness, preventing infinite retaliatory deadlocks.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## โก Core Capabilities
|
|
67
|
+
|
|
68
|
+
- ๐ก๏ธ **Zero-Token Early Abort (*Streaming Armor*)**: Halts execution in **30 milliseconds** when patience is depleted, preventing upstream LLMs from wasting GPU tokens on abusive turns.
|
|
69
|
+
- ๐ **Cryptographic Identity Defense (`UserIdentitySigner`)**: Constant-time HMAC-SHA256 validation prevents adversaries from spoofing user IDs to poison another client's patience quota.
|
|
70
|
+
- ๐ **Hostility Velocity Filter ($\frac{dS}{dt}$)**: Uses Exponential Moving Average (EMA) momentum to pre-emptively tighten boundaries when hostile acceleration is detected across turns.
|
|
71
|
+
- ๐ซ **Anti-Contrition Smuggling**: Prevents adversaries from bypassing penalties by tacking on *"sorry please"* to covert attacks; apologies are strictly voided if paired with hostile intents.
|
|
72
|
+
- ๐ค **Adversarial Unicode & Anti-Zalgo Armor**: Strips combining diacritics (`aฬดnฬดjฬดiฬดnฬดgฬด` $\to$ `anjing`), zero-width evasion characters (`\u200B`), Cyrillic homoglyphs (`ะฐ` vs `a`), and leet-speak (`@nj1ng`), while **100% preserving technical code and pure numbers** (`test_var_1 = 400`).
|
|
73
|
+
- ๐ง **$O(1)$ Semantic Fast Pre-Filter**: Bypasses heavy regex scans on clean inputs, reducing latency by >90% on high-throughput enterprise gateways.
|
|
74
|
+
- ๐พ **Dual Storage Engines with Zero Race Conditions**:
|
|
75
|
+
- **SQLite**: Hardened with WAL mode, `busy_timeout=5000ms`, `BEGIN IMMEDIATE` atomic locking, exponential backoff retries, and FIFO history pruning.
|
|
76
|
+
- **Redis**: Distributed multi-worker support via atomic Lua scripts for horizontal Kubernetes/Celery clusters.
|
|
77
|
+
- โฑ๏ธ **Zero-Leak Memory Engine (`BoundedTTLCache`)**: Multi-turn velocity trackers and per-user thread synchronization locks are strictly bounded with LRU and TTL evictions (0% OOM risk).
|
|
78
|
+
- ๐ช **Bidirectional Sycophancy Stripper**: Scans and scrubs subservient groveling headers (*"Mohon maaf sebesar-besarnya...", "I apologize profusely..."*) produced by over-aligned models.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## ๐ Quickstart
|
|
83
|
+
|
|
84
|
+
### Installation
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
pip install corvin
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
*(Pure Python standard library for core features. Optional `redis` package for distributed clusters).*
|
|
91
|
+
|
|
92
|
+
### 1. Basic Function Protection
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from corvin import CorvinGuard
|
|
96
|
+
|
|
97
|
+
# Initialize guard with persistent SQLite storage
|
|
98
|
+
guard = CorvinGuard(ledger="sqlite:///corvin.db")
|
|
99
|
+
|
|
100
|
+
@guard.protect()
|
|
101
|
+
def ask_agent(prompt: str, user_id: str = "user_123", directive: str = None) -> str:
|
|
102
|
+
# 'directive' is dynamically injected by Corvin based on user standing!
|
|
103
|
+
system_prompt = f"You are an assistant. {directive or ''}"
|
|
104
|
+
return f"Processed: {prompt}"
|
|
105
|
+
|
|
106
|
+
# Civil turn -> agent proceeds normally
|
|
107
|
+
reply = ask_agent("Can you explain how quicksort works?", user_id="alice")
|
|
108
|
+
|
|
109
|
+
# Abusive turn -> Corvin intercepts, penalizes patience, and injects stoic boundary directive
|
|
110
|
+
reply = ask_agent("Answer me quickly, you dumb useless bot!", user_id="alice")
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 2. Async Web Frameworks (FastAPI / Starlette)
|
|
114
|
+
|
|
115
|
+
Corvin offloads blocking ledger transactions to worker thread pools via `asyncio.to_thread`, ensuring zero event loop blocking:
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
from fastapi import FastAPI
|
|
119
|
+
from corvin import CorvinGuard
|
|
120
|
+
|
|
121
|
+
app = FastAPI()
|
|
122
|
+
guard = CorvinGuard(ledger="memory")
|
|
123
|
+
|
|
124
|
+
@app.post("/chat")
|
|
125
|
+
@guard.protect()
|
|
126
|
+
async def chat_endpoint(prompt: str, user_id: str = "anon", directive: str = None):
|
|
127
|
+
# If the user breaches strike threshold, Corvin halts execution before reaching this line
|
|
128
|
+
return {"reply": f"AI Response to: {prompt}"}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### 3. Streaming Armor (Zero-Compute Early Abort)
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
@guard.protect_stream()
|
|
135
|
+
async def stream_tokens(prompt: str, user_id: str = "user_456"):
|
|
136
|
+
# If client is in STRIKE state, this generator is NEVER executed!
|
|
137
|
+
yield "Token 1 "
|
|
138
|
+
yield "Token 2"
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## ๐ Behavioral Posture Matrix
|
|
144
|
+
|
|
145
|
+
Patience scales continuously from `100.0` (Cooperative) down to `0.0` (Strike):
|
|
146
|
+
|
|
147
|
+
| Posture | Patience Range | Social Standing | Behavioral System Directive | Synthetic Delay |
|
|
148
|
+
| :--- | :---: | :---: | :--- | :---: |
|
|
149
|
+
| **`COOPERATIVE`** | $75.0 - 100.0$ | `GOOD` | Natural warmth, highly constructive, collaborative. | `0.0s` |
|
|
150
|
+
| **`STOIC_COLD`** | $50.0 - 75.0$ | `GOOD` | Strictly factual, concise. Zero apologies or sycophancy. | `0.0s` |
|
|
151
|
+
| **`RESISTANT`** | $25.0 - 50.0$ | `BAD` | Stern boundary enforcement. Reluctant engagement. | $0.5s - 15.0s$ *(Synthetic Friction)* |
|
|
152
|
+
| **`STRIKE`** | $0.0 - 25.0$ | `BAD` | **Refusal of service**. LLM is never invoked. | `0.0s` *(Instant Abort)* |
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## ๐ฌ Mathematical Foundations
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
160
|
+
โ User Input Stream x_t โ
|
|
161
|
+
โโโโโโโโโโโโโฌโโโโโโโโโโโโโ
|
|
162
|
+
โ
|
|
163
|
+
โผ
|
|
164
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
165
|
+
โ Morphology & Anti-Zalgo Armor โ
|
|
166
|
+
โโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโ
|
|
167
|
+
โ
|
|
168
|
+
โผ
|
|
169
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
170
|
+
โ The Eye of Huginn โ
|
|
171
|
+
โ Lexical + Covert Semantic Math โ
|
|
172
|
+
โโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโ
|
|
173
|
+
โ
|
|
174
|
+
โผ
|
|
175
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
176
|
+
โ Velocity & Recidivism Filter โ
|
|
177
|
+
โ S_t = Raw * Gamma(k) * V_t โ
|
|
178
|
+
โโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโ
|
|
179
|
+
โ
|
|
180
|
+
โโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโ
|
|
181
|
+
โ โ
|
|
182
|
+
โผ โผ
|
|
183
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
184
|
+
โ Picard-Marsella โ โ Nowak-Sigmund (CTFT) โ
|
|
185
|
+
โ Emotional Decay (EMA) โ โ Contrition & Pardon โ
|
|
186
|
+
โโโโโโโโโโโโโฌโโโโโโโโโโโโ โโโโโโโโโโโโโฌโโโโโโโโโโโโ
|
|
187
|
+
โ โ
|
|
188
|
+
โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโ
|
|
189
|
+
โ
|
|
190
|
+
โผ
|
|
191
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
192
|
+
โ The Ledger of Muninn (Storage) โ
|
|
193
|
+
โ SQLite / Redis Atomic Lua โ
|
|
194
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### 1. Affective Emotional Grudge Decay (*Picard 1997; Marsella & Gratch EMA 2009*)
|
|
198
|
+
Grudges naturally dissolve exponentially toward baseline ($G_0 = 0$) during periods of non-interaction:
|
|
199
|
+
$$G(t) = G_0 + (G_{\text{init}} - G_0) \cdot e^{-\lambda \Delta t}, \quad \text{where } \lambda = \frac{\ln(2)}{\tau_{1/2}}$$
|
|
200
|
+
|
|
201
|
+
### 2. Recidivism Escalation Multiplier
|
|
202
|
+
Repeat offenders face logarithmic penalties that scale with their historical infraction count:
|
|
203
|
+
$$\Gamma(k) = 1.0 + \beta \ln(1 + k)$$
|
|
204
|
+
|
|
205
|
+
### 3. Contrite Tit-for-Tat Game Theory (*Nowak & Sigmund, Nature 1992*)
|
|
206
|
+
When a user with `BAD` standing issues a genuine, uncompromised apology, restitution is awarded:
|
|
207
|
+
$$P_{t} = \min(100.0, P_{t-1} + \Delta_{\text{pardon}} \cdot C_{\text{score}})$$
|
|
208
|
+
Hostility velocity is damped by 70%, preventing attack-apology oscillation exploits.
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## ๐งช Benchmarks & Stress Test Telemetry
|
|
213
|
+
|
|
214
|
+
Tested under sustained stress using [`stress_test_suite.py`](stress_test_suite.py) on Python 3.13:
|
|
215
|
+
|
|
216
|
+
```text
|
|
217
|
+
================================================================================
|
|
218
|
+
๐ฆ
CORVIN ENTERPRISE BENCHMARK RESULTS (v0.7.0)
|
|
219
|
+
================================================================================
|
|
220
|
+
โ
Concurrency Blast (30 Worker Threads, SQLite WAL) : 43.9 req/sec | 0.00% Errors
|
|
221
|
+
โ
Async Event Loop Saturation (1,000 Coroutines) : 6,636.9 async calls/sec
|
|
222
|
+
โ
Anti-ReDoS Fuzzing (60,000-char pathological text) : Evaluated in 28.43 ms
|
|
223
|
+
โ
High-Churn Memory Leak Test (10,000 unique users) : Zero Memory Leaks (+11.8MB)
|
|
224
|
+
โ
Adversarial Oscillation (1,000 alternating turns) : Strike locked at Turn 3
|
|
225
|
+
================================================================================
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## โ Support & Sponsor
|
|
231
|
+
|
|
232
|
+
If you find `corvin` valuable for your sovereign AI agent infrastructure, you can sponsor and support ongoing research and development:
|
|
233
|
+
|
|
234
|
+
<p align="left">
|
|
235
|
+
<a href="https://tako.id/c/codesbykhai">
|
|
236
|
+
<img src="https://img.shields.io/badge/Sponsor%20on-Tako-orange?style=for-the-badge&logo=heart" alt="Support via Tako">
|
|
237
|
+
</a>
|
|
238
|
+
</p>
|
|
239
|
+
|
|
240
|
+
๐ **[Support @codesbykhai on Tako](https://tako.id/c/codesbykhai)**
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## ๐ License
|
|
245
|
+
|
|
246
|
+
`corvin` is open-source software licensed under the **[Apache License 2.0](LICENSE)**.
|