collective-intelligence-overlay 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.
- collective_intelligence_overlay-0.1.0/LICENSE +202 -0
- collective_intelligence_overlay-0.1.0/NOTICE +4 -0
- collective_intelligence_overlay-0.1.0/PKG-INFO +131 -0
- collective_intelligence_overlay-0.1.0/README.md +105 -0
- collective_intelligence_overlay-0.1.0/pyproject.toml +78 -0
- collective_intelligence_overlay-0.1.0/pyproject.toml.orig +70 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/__init__.py +5 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/accounting.py +37 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/adapters/a2a.py +227 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/adapters/http_limits.py +39 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/adapters/maf.py +27 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/adapters/mcp.py +38 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/artifacts.py +38 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/cli.py +123 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/config.py +74 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/demo.py +255 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/evaluation.py +133 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/migrations/env.py +8 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/migrations/versions/0001_initial.py +58 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/models.py +195 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/overlay.py +267 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/peer.py +264 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/policy.py +67 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/policy.rego +40 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/py.typed +0 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/reference.py +154 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/reference_mcp.py +20 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/schemas/capability.json +231 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/schemas/event.json +265 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/schemas/evidence.json +273 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/security.py +67 -0
- collective_intelligence_overlay-0.1.0/src/collective_intelligence_overlay/storage.py +293 -0
|
@@ -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.
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: collective-intelligence-overlay
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Evidence sharing and local admission for reusable agent capabilities
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
License-File: NOTICE
|
|
8
|
+
Requires-Dist: pydantic>=2.13.5,<3
|
|
9
|
+
Requires-Dist: httpx>=0.28.1,<1
|
|
10
|
+
Requires-Dist: sqlalchemy>=2.1.1,<3
|
|
11
|
+
Requires-Dist: alembic>=1.20,<2
|
|
12
|
+
Requires-Dist: pg8000>=1.31,<2
|
|
13
|
+
Requires-Dist: securesystemslib[crypto]>=1.5.1,<2
|
|
14
|
+
Requires-Dist: pyjwt[crypto]>=2.12,<3
|
|
15
|
+
Requires-Dist: agent-framework-core>=1.19,<1.20 ; extra == 'agents'
|
|
16
|
+
Requires-Dist: a2a-sdk[http-server]>=1.1.5,<1.2 ; extra == 'agents'
|
|
17
|
+
Requires-Dist: mcp>=2.2,<2.3 ; extra == 'agents'
|
|
18
|
+
Requires-Dist: uvicorn>=0.41,<1 ; extra == 'agents'
|
|
19
|
+
Requires-Dist: httpx2>=2,<3 ; extra == 'agents'
|
|
20
|
+
Requires-Dist: agent-framework-openai>=1.14.4,<1.15 ; extra == 'model'
|
|
21
|
+
Requires-Python: >=3.12, <3.13
|
|
22
|
+
Project-URL: Repository, https://github.com/kadubon/collective-intelligence-overlay
|
|
23
|
+
Provides-Extra: agents
|
|
24
|
+
Provides-Extra: model
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# Collective Intelligence Overlay
|
|
28
|
+
|
|
29
|
+
**Evidence is shared; admission is local.**
|
|
30
|
+
|
|
31
|
+
A Python overlay for teams that want agents to exchange reusable tools and procedures
|
|
32
|
+
without treating every generated result as verified. Each participant keeps its own
|
|
33
|
+
keys, database, acceptance policy and budget. A receiver can inspect a candidate,
|
|
34
|
+
request more checking, reject it, or reuse it under a specific contract.
|
|
35
|
+
|
|
36
|
+
The package connects Microsoft Agent Framework (MAF), A2A and MCP. It is not an
|
|
37
|
+
agent runtime or a central manager. Existing SDKs run tools and compose workflows;
|
|
38
|
+
the overlay records evidence, qualifies reuse and stops known-invalid dependencies.
|
|
39
|
+
|
|
40
|
+
[日本語](README.ja.md) · [Tutorial](docs/quickstart.md) · [Architecture](docs/architecture.md)
|
|
41
|
+
|
|
42
|
+
## What works
|
|
43
|
+
|
|
44
|
+
- Signed, versioned capability and evidence records, including PASS / FAIL / UNKNOWN.
|
|
45
|
+
- Receiver-specific OPA decisions: ACCEPT / REQUALIFY / REJECT / UNKNOWN.
|
|
46
|
+
- PostgreSQL persistence, duplicate/conflict detection, budgets and fenced result commits.
|
|
47
|
+
- Real A2A HTTP exchange, MAF function middleware/workflow composition and MCP HTTP calls.
|
|
48
|
+
- A three-process demo: form CSV tools, independently check outputs, reuse an HTML
|
|
49
|
+
report workflow, then invalidate it by revoking its aggregate dependency.
|
|
50
|
+
- Typed costs and an explicitly limited deterministic comparison.
|
|
51
|
+
|
|
52
|
+
A signature establishes origin, not truth. Sample checks do not prove correctness on
|
|
53
|
+
all future data. Distinct local identities are not independent organizations or
|
|
54
|
+
statistically independent evidence. This software does not prove intelligence growth.
|
|
55
|
+
|
|
56
|
+
## Run from source
|
|
57
|
+
|
|
58
|
+
Python 3.12, [uv](https://docs.astral.sh/uv/), PostgreSQL 16 and the OPA binary are
|
|
59
|
+
required for the reference path. No model API key is needed. There is no broker,
|
|
60
|
+
vector database, mandatory cloud service or always-running OPA server.
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
git clone https://github.com/kadubon/collective-intelligence-overlay.git
|
|
64
|
+
cd collective-intelligence-overlay
|
|
65
|
+
uv sync --all-extras --frozen
|
|
66
|
+
uv run python scripts/fetch_opa.py
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Start a **dedicated development** PostgreSQL instance. The setup account must be able
|
|
70
|
+
to create roles and databases. See the [tutorial](docs/quickstart.md) for Docker,
|
|
71
|
+
Linux and PowerShell commands. Then:
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
export CIO_TEST_DATABASE_URL='postgresql+pg8000://postgres:development-only@127.0.0.1:5432/postgres'
|
|
75
|
+
export CIO_OPA="$PWD/.local/bin/opa"
|
|
76
|
+
uv run collective-intelligence-overlay demo --directory .local/demo
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Expected fields: `processes: 3`, `admission: ACCEPT`, report total `117.00`,
|
|
80
|
+
`changed_environment: REQUALIFY`, `after_dependency_revocation: REJECT`.
|
|
81
|
+
Timings vary. The command preserves owner-local artifacts and databases and stops
|
|
82
|
+
its child processes. Use a new output directory for another run.
|
|
83
|
+
|
|
84
|
+
Release/publication status is tracked in [releasing](docs/releasing.md); source
|
|
85
|
+
instructions do not assume that a package has already reached PyPI.
|
|
86
|
+
|
|
87
|
+
## Add to an existing agent
|
|
88
|
+
|
|
89
|
+
Importing the core never opens a database or runs a migration. The host supplies
|
|
90
|
+
an `Overlay`, a pinned `UseRequest` and a trusted local operation:
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
decision = await overlay.qualify(request)
|
|
94
|
+
result = await overlay.execute(request, registered_operation)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
`execute` requalifies immediately before calling the operation. A previous ACCEPT
|
|
98
|
+
is not a permanent permission. [Integration](docs/integrations.md) shows MAF
|
|
99
|
+
middleware and the real, opt-in model example. See [API and CLI](docs/api.md) for
|
|
100
|
+
configuration, exceptions, cancellation and the operator/agent boundary.
|
|
101
|
+
|
|
102
|
+
For example, a verifier's PASS for `csv-sum@1` in environment `reference=1` does not
|
|
103
|
+
admit it in `reference=2`. The receiver requests requalification. A valid in-scope
|
|
104
|
+
counterexample is retained alongside the PASS and takes precedence in the standard policy.
|
|
105
|
+
|
|
106
|
+
## Trust and operation
|
|
107
|
+
|
|
108
|
+
Peers authenticate with distinct pinned Ed25519 identities. Local Rego policy,
|
|
109
|
+
keys and budgets must be protected from the agent process. Evidence sharing is
|
|
110
|
+
disabled by default; the demonstration enables it for its configured peers.
|
|
111
|
+
The DB/host operator is trusted. A malicious infrastructure administrator is outside
|
|
112
|
+
this model. See [security](docs/security.md) and [deployment](docs/deployment.md).
|
|
113
|
+
|
|
114
|
+
```sh
|
|
115
|
+
uv run ruff check .
|
|
116
|
+
uv run ruff format --check .
|
|
117
|
+
uv run mypy
|
|
118
|
+
uv run pytest
|
|
119
|
+
uv build
|
|
120
|
+
uv run twine check --strict dist/*
|
|
121
|
+
uv run python scripts/check_package.py
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Integration/E2E tests require PostgreSQL and OPA; missing services are explicit skips,
|
|
125
|
+
not production validation. Paid model calls are off by default. Current checks and
|
|
126
|
+
unverified boundaries are in [validation](docs/validation.md). Windows and Linux are
|
|
127
|
+
the initial target platforms; the network reference deployment is Linux-oriented.
|
|
128
|
+
|
|
129
|
+
New code is Apache-2.0. See [LICENSE](LICENSE), [NOTICE](NOTICE),
|
|
130
|
+
[dependency compatibility/licensing](docs/compatibility.md),
|
|
131
|
+
[research mapping](docs/research-mapping.md), and [contributing](CONTRIBUTING.md).
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Collective Intelligence Overlay
|
|
2
|
+
|
|
3
|
+
**Evidence is shared; admission is local.**
|
|
4
|
+
|
|
5
|
+
A Python overlay for teams that want agents to exchange reusable tools and procedures
|
|
6
|
+
without treating every generated result as verified. Each participant keeps its own
|
|
7
|
+
keys, database, acceptance policy and budget. A receiver can inspect a candidate,
|
|
8
|
+
request more checking, reject it, or reuse it under a specific contract.
|
|
9
|
+
|
|
10
|
+
The package connects Microsoft Agent Framework (MAF), A2A and MCP. It is not an
|
|
11
|
+
agent runtime or a central manager. Existing SDKs run tools and compose workflows;
|
|
12
|
+
the overlay records evidence, qualifies reuse and stops known-invalid dependencies.
|
|
13
|
+
|
|
14
|
+
[日本語](README.ja.md) · [Tutorial](docs/quickstart.md) · [Architecture](docs/architecture.md)
|
|
15
|
+
|
|
16
|
+
## What works
|
|
17
|
+
|
|
18
|
+
- Signed, versioned capability and evidence records, including PASS / FAIL / UNKNOWN.
|
|
19
|
+
- Receiver-specific OPA decisions: ACCEPT / REQUALIFY / REJECT / UNKNOWN.
|
|
20
|
+
- PostgreSQL persistence, duplicate/conflict detection, budgets and fenced result commits.
|
|
21
|
+
- Real A2A HTTP exchange, MAF function middleware/workflow composition and MCP HTTP calls.
|
|
22
|
+
- A three-process demo: form CSV tools, independently check outputs, reuse an HTML
|
|
23
|
+
report workflow, then invalidate it by revoking its aggregate dependency.
|
|
24
|
+
- Typed costs and an explicitly limited deterministic comparison.
|
|
25
|
+
|
|
26
|
+
A signature establishes origin, not truth. Sample checks do not prove correctness on
|
|
27
|
+
all future data. Distinct local identities are not independent organizations or
|
|
28
|
+
statistically independent evidence. This software does not prove intelligence growth.
|
|
29
|
+
|
|
30
|
+
## Run from source
|
|
31
|
+
|
|
32
|
+
Python 3.12, [uv](https://docs.astral.sh/uv/), PostgreSQL 16 and the OPA binary are
|
|
33
|
+
required for the reference path. No model API key is needed. There is no broker,
|
|
34
|
+
vector database, mandatory cloud service or always-running OPA server.
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
git clone https://github.com/kadubon/collective-intelligence-overlay.git
|
|
38
|
+
cd collective-intelligence-overlay
|
|
39
|
+
uv sync --all-extras --frozen
|
|
40
|
+
uv run python scripts/fetch_opa.py
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Start a **dedicated development** PostgreSQL instance. The setup account must be able
|
|
44
|
+
to create roles and databases. See the [tutorial](docs/quickstart.md) for Docker,
|
|
45
|
+
Linux and PowerShell commands. Then:
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
export CIO_TEST_DATABASE_URL='postgresql+pg8000://postgres:development-only@127.0.0.1:5432/postgres'
|
|
49
|
+
export CIO_OPA="$PWD/.local/bin/opa"
|
|
50
|
+
uv run collective-intelligence-overlay demo --directory .local/demo
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Expected fields: `processes: 3`, `admission: ACCEPT`, report total `117.00`,
|
|
54
|
+
`changed_environment: REQUALIFY`, `after_dependency_revocation: REJECT`.
|
|
55
|
+
Timings vary. The command preserves owner-local artifacts and databases and stops
|
|
56
|
+
its child processes. Use a new output directory for another run.
|
|
57
|
+
|
|
58
|
+
Release/publication status is tracked in [releasing](docs/releasing.md); source
|
|
59
|
+
instructions do not assume that a package has already reached PyPI.
|
|
60
|
+
|
|
61
|
+
## Add to an existing agent
|
|
62
|
+
|
|
63
|
+
Importing the core never opens a database or runs a migration. The host supplies
|
|
64
|
+
an `Overlay`, a pinned `UseRequest` and a trusted local operation:
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
decision = await overlay.qualify(request)
|
|
68
|
+
result = await overlay.execute(request, registered_operation)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
`execute` requalifies immediately before calling the operation. A previous ACCEPT
|
|
72
|
+
is not a permanent permission. [Integration](docs/integrations.md) shows MAF
|
|
73
|
+
middleware and the real, opt-in model example. See [API and CLI](docs/api.md) for
|
|
74
|
+
configuration, exceptions, cancellation and the operator/agent boundary.
|
|
75
|
+
|
|
76
|
+
For example, a verifier's PASS for `csv-sum@1` in environment `reference=1` does not
|
|
77
|
+
admit it in `reference=2`. The receiver requests requalification. A valid in-scope
|
|
78
|
+
counterexample is retained alongside the PASS and takes precedence in the standard policy.
|
|
79
|
+
|
|
80
|
+
## Trust and operation
|
|
81
|
+
|
|
82
|
+
Peers authenticate with distinct pinned Ed25519 identities. Local Rego policy,
|
|
83
|
+
keys and budgets must be protected from the agent process. Evidence sharing is
|
|
84
|
+
disabled by default; the demonstration enables it for its configured peers.
|
|
85
|
+
The DB/host operator is trusted. A malicious infrastructure administrator is outside
|
|
86
|
+
this model. See [security](docs/security.md) and [deployment](docs/deployment.md).
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
uv run ruff check .
|
|
90
|
+
uv run ruff format --check .
|
|
91
|
+
uv run mypy
|
|
92
|
+
uv run pytest
|
|
93
|
+
uv build
|
|
94
|
+
uv run twine check --strict dist/*
|
|
95
|
+
uv run python scripts/check_package.py
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Integration/E2E tests require PostgreSQL and OPA; missing services are explicit skips,
|
|
99
|
+
not production validation. Paid model calls are off by default. Current checks and
|
|
100
|
+
unverified boundaries are in [validation](docs/validation.md). Windows and Linux are
|
|
101
|
+
the initial target platforms; the network reference deployment is Linux-oriented.
|
|
102
|
+
|
|
103
|
+
New code is Apache-2.0. See [LICENSE](LICENSE), [NOTICE](NOTICE),
|
|
104
|
+
[dependency compatibility/licensing](docs/compatibility.md),
|
|
105
|
+
[research mapping](docs/research-mapping.md), and [contributing](CONTRIBUTING.md).
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["uv_build>=0.12.19,<0.13"]
|
|
3
|
+
build-backend = "uv_build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "collective-intelligence-overlay"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Evidence sharing and local admission for reusable agent capabilities"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.12,<3.13"
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
license-files = [
|
|
13
|
+
"LICENSE",
|
|
14
|
+
"NOTICE",
|
|
15
|
+
]
|
|
16
|
+
dependencies = [
|
|
17
|
+
"pydantic>=2.13.5,<3",
|
|
18
|
+
"httpx>=0.28.1,<1",
|
|
19
|
+
"sqlalchemy>=2.1.1,<3",
|
|
20
|
+
"alembic>=1.20,<2",
|
|
21
|
+
"pg8000>=1.31,<2",
|
|
22
|
+
"securesystemslib[crypto]>=1.5.1,<2",
|
|
23
|
+
"pyjwt[crypto]>=2.12,<3",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[project.optional-dependencies]
|
|
27
|
+
agents = [
|
|
28
|
+
"agent-framework-core>=1.19,<1.20",
|
|
29
|
+
"a2a-sdk[http-server]>=1.1.5,<1.2",
|
|
30
|
+
"mcp>=2.2,<2.3",
|
|
31
|
+
"uvicorn>=0.41,<1",
|
|
32
|
+
"httpx2>=2,<3",
|
|
33
|
+
]
|
|
34
|
+
model = ["agent-framework-openai>=1.14.4,<1.15"]
|
|
35
|
+
|
|
36
|
+
[project.scripts]
|
|
37
|
+
collective-intelligence-overlay = "collective_intelligence_overlay.cli:main"
|
|
38
|
+
|
|
39
|
+
[project.urls]
|
|
40
|
+
Repository = "https://github.com/kadubon/collective-intelligence-overlay"
|
|
41
|
+
|
|
42
|
+
[dependency-groups]
|
|
43
|
+
dev = [
|
|
44
|
+
"pytest>=9,<10",
|
|
45
|
+
"pytest-asyncio>=1,<2",
|
|
46
|
+
"hypothesis>=6,<7",
|
|
47
|
+
"ruff>=0.15,<1",
|
|
48
|
+
"mypy>=1.19,<2",
|
|
49
|
+
"pytest-cov>=7,<8",
|
|
50
|
+
"twine>=6,<7",
|
|
51
|
+
"pip-audit>=2.10,<3",
|
|
52
|
+
"cyclonedx-bom>=7,<8",
|
|
53
|
+
"pip-licenses>=5,<6",
|
|
54
|
+
"types-protobuf>=7.35.1.20260906",
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
[tool.pytest.ini_options]
|
|
58
|
+
testpaths = ["tests"]
|
|
59
|
+
asyncio_mode = "auto"
|
|
60
|
+
|
|
61
|
+
[tool.ruff]
|
|
62
|
+
target-version = "py312"
|
|
63
|
+
line-length = 100
|
|
64
|
+
|
|
65
|
+
[tool.ruff.lint]
|
|
66
|
+
select = [
|
|
67
|
+
"E",
|
|
68
|
+
"F",
|
|
69
|
+
"I",
|
|
70
|
+
"UP",
|
|
71
|
+
"B",
|
|
72
|
+
"ASYNC",
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
[tool.mypy]
|
|
76
|
+
python_version = "3.12"
|
|
77
|
+
strict = true
|
|
78
|
+
packages = ["collective_intelligence_overlay"]
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["uv_build>=0.12.19,<0.13"]
|
|
3
|
+
build-backend = "uv_build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "collective-intelligence-overlay"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Evidence sharing and local admission for reusable agent capabilities"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.12,<3.13"
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
license-files = ["LICENSE", "NOTICE"]
|
|
13
|
+
dependencies = [
|
|
14
|
+
"pydantic>=2.13.5,<3",
|
|
15
|
+
"httpx>=0.28.1,<1",
|
|
16
|
+
"sqlalchemy>=2.1.1,<3",
|
|
17
|
+
"alembic>=1.20,<2",
|
|
18
|
+
"pg8000>=1.31,<2",
|
|
19
|
+
"securesystemslib[crypto]>=1.5.1,<2",
|
|
20
|
+
"pyjwt[crypto]>=2.12,<3",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.optional-dependencies]
|
|
24
|
+
agents = [
|
|
25
|
+
"agent-framework-core>=1.19,<1.20",
|
|
26
|
+
"a2a-sdk[http-server]>=1.1.5,<1.2",
|
|
27
|
+
"mcp>=2.2,<2.3",
|
|
28
|
+
"uvicorn>=0.41,<1",
|
|
29
|
+
"httpx2>=2,<3",
|
|
30
|
+
]
|
|
31
|
+
model = [
|
|
32
|
+
"agent-framework-openai>=1.14.4,<1.15",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.scripts]
|
|
36
|
+
collective-intelligence-overlay = "collective_intelligence_overlay.cli:main"
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
Repository = "https://github.com/kadubon/collective-intelligence-overlay"
|
|
40
|
+
|
|
41
|
+
[dependency-groups]
|
|
42
|
+
dev = [
|
|
43
|
+
"pytest>=9,<10",
|
|
44
|
+
"pytest-asyncio>=1,<2",
|
|
45
|
+
"hypothesis>=6,<7",
|
|
46
|
+
"ruff>=0.15,<1",
|
|
47
|
+
"mypy>=1.19,<2",
|
|
48
|
+
"pytest-cov>=7,<8",
|
|
49
|
+
"twine>=6,<7",
|
|
50
|
+
"pip-audit>=2.10,<3",
|
|
51
|
+
"cyclonedx-bom>=7,<8",
|
|
52
|
+
"pip-licenses>=5,<6",
|
|
53
|
+
"types-protobuf>=7.35.1.20260906",
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
[tool.pytest.ini_options]
|
|
57
|
+
testpaths = ["tests"]
|
|
58
|
+
asyncio_mode = "auto"
|
|
59
|
+
|
|
60
|
+
[tool.ruff]
|
|
61
|
+
target-version = "py312"
|
|
62
|
+
line-length = 100
|
|
63
|
+
|
|
64
|
+
[tool.ruff.lint]
|
|
65
|
+
select = ["E", "F", "I", "UP", "B", "ASYNC"]
|
|
66
|
+
|
|
67
|
+
[tool.mypy]
|
|
68
|
+
python_version = "3.12"
|
|
69
|
+
strict = true
|
|
70
|
+
packages = ["collective_intelligence_overlay"]
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""Typed accounting: unavailable, estimated and measured quantities stay distinct."""
|
|
2
|
+
|
|
3
|
+
from collections import Counter, defaultdict
|
|
4
|
+
from decimal import Decimal
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from .models import Event
|
|
8
|
+
from .storage import Conflict
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def metrics(events: list[Event]) -> dict[str, Any]:
|
|
12
|
+
unique: dict[tuple[str, str], Event] = {}
|
|
13
|
+
for event in events:
|
|
14
|
+
key = (event.issuer, event.id)
|
|
15
|
+
if key in unique and unique[key] != event:
|
|
16
|
+
raise Conflict("event content conflict")
|
|
17
|
+
unique[key] = event
|
|
18
|
+
totals: dict[tuple[str, str, str], Decimal] = defaultdict(Decimal)
|
|
19
|
+
missing: Counter[tuple[str, str]] = Counter()
|
|
20
|
+
for event in unique.values():
|
|
21
|
+
for cost in event.costs:
|
|
22
|
+
if cost.quantity is None:
|
|
23
|
+
missing[cost.category, cost.unit] += 1
|
|
24
|
+
else:
|
|
25
|
+
totals[cost.category, cost.unit, cost.status] += cost.quantity
|
|
26
|
+
return {
|
|
27
|
+
"events": len(unique),
|
|
28
|
+
"actions": dict(Counter(e.action for e in unique.values())),
|
|
29
|
+
"outcomes": dict(Counter(str(e.outcome) for e in unique.values() if e.outcome)),
|
|
30
|
+
"costs": [
|
|
31
|
+
{"category": c, "unit": u, "status": s, "quantity": str(q)}
|
|
32
|
+
for (c, u, s), q in sorted(totals.items())
|
|
33
|
+
],
|
|
34
|
+
"unavailable": [
|
|
35
|
+
{"category": c, "unit": u, "count": n} for (c, u), n in sorted(missing.items())
|
|
36
|
+
],
|
|
37
|
+
}
|