ucde 0.2.0__tar.gz → 0.2.1__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.
- ucde-0.2.1/PKG-INFO +302 -0
- ucde-0.2.1/README.md +265 -0
- {ucde-0.2.0 → ucde-0.2.1}/pyproject.toml +14 -2
- {ucde-0.2.0 → ucde-0.2.1}/python/ucde/__init__.py +1 -1
- {ucde-0.2.0 → ucde-0.2.1}/python/ucde/cli.py +6 -0
- ucde-0.2.1/python/ucde.egg-info/PKG-INFO +302 -0
- {ucde-0.2.0 → ucde-0.2.1}/python/ucde.egg-info/SOURCES.txt +1 -0
- {ucde-0.2.0 → ucde-0.2.1}/tests/test_cli.py +19 -0
- ucde-0.2.1/tests/test_distribution.py +48 -0
- {ucde-0.2.0 → ucde-0.2.1}/tests/test_mcp.py +17 -2
- ucde-0.2.0/PKG-INFO +0 -171
- ucde-0.2.0/README.md +0 -142
- ucde-0.2.0/python/ucde.egg-info/PKG-INFO +0 -171
- {ucde-0.2.0 → ucde-0.2.1}/LICENSE +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/python/ucde/__main__.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/python/ucde/archive.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/python/ucde/chain.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/python/ucde/chain_audit.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/python/ucde/crate.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/python/ucde/mcp_server.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/python/ucde/model.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/python/ucde/ollama.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/python/ucde/packet.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/python/ucde/provenance.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/python/ucde/py.typed +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/python/ucde/ranking.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/python/ucde/store.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/python/ucde.egg-info/dependency_links.txt +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/python/ucde.egg-info/entry_points.txt +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/python/ucde.egg-info/requires.txt +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/python/ucde.egg-info/top_level.txt +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/setup.cfg +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/tests/test_agicam.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/tests/test_archive_export.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/tests/test_archive_verification.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/tests/test_benchmark.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/tests/test_chain_audit.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/tests/test_chain_integration.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/tests/test_chain_writer.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/tests/test_crate.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/tests/test_integrity.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/tests/test_jarvis_pilot.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/tests/test_memory.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/tests/test_ollama.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/tests/test_packet.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/tests/test_provenance.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/tests/test_real_data_evaluate.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/tests/test_release_batches.py +0 -0
- {ucde-0.2.0 → ucde-0.2.1}/tests/test_release_replay.py +0 -0
ucde-0.2.1/PKG-INFO
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ucde
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: Version-controlled research evidence: search what was known at any past date, with citations, verifiable history and a read-only MCP server
|
|
5
|
+
Author: Muhammad Q Farooqi
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://ucde-evidence.closedtiger256.chatgpt.site/
|
|
8
|
+
Project-URL: Documentation, https://github.com/mqfarooqi1/ucde#guide
|
|
9
|
+
Project-URL: Repository, https://github.com/mqfarooqi1/ucde
|
|
10
|
+
Project-URL: Issues, https://github.com/mqfarooqi1/ucde/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/mqfarooqi1/ucde/blob/main/CHANGELOG.md
|
|
12
|
+
Keywords: research data,provenance,evidence retrieval,reproducibility,audit trail,bitemporal,time travel,hash chain,ro-crate,w3c-prov,plant breeding,phenotyping,sqlite,fts5,bm25,mcp,model context protocol,ai agents,agent memory
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
25
|
+
Classifier: Topic :: Database
|
|
26
|
+
Classifier: Topic :: Database :: Database Engines/Servers
|
|
27
|
+
Classifier: Topic :: Scientific/Engineering
|
|
28
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
29
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
30
|
+
Classifier: Typing :: Typed
|
|
31
|
+
Requires-Python: >=3.11
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
License-File: LICENSE
|
|
34
|
+
Provides-Extra: mcp
|
|
35
|
+
Requires-Dist: mcp==2.3.0; extra == "mcp"
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
<!-- mcp-name: io.github.mqfarooqi1/ucde -->
|
|
39
|
+
<p align="center"><a href="https://ucde-evidence.closedtiger256.chatgpt.site/"><img src="https://raw.githubusercontent.com/mqfarooqi1/ucde/main/docs/assets/ucde-logo.png" alt="UCDE logo" width="96" height="96"></a></p>
|
|
40
|
+
|
|
41
|
+
<h1 align="center">UCDE: Universal Cognitive Data Engine</h1>
|
|
42
|
+
|
|
43
|
+
<p align="center"><strong>Version control for research evidence.</strong> Search what was known at any past date, see where every answer came from, and give AI agents the same cited, read-only view.</p>
|
|
44
|
+
|
|
45
|
+
<p align="center">
|
|
46
|
+
<a href="https://pypi.org/project/ucde/"><img src="https://img.shields.io/pypi/v/ucde" alt="PyPI version"></a>
|
|
47
|
+
<a href="https://pypi.org/project/ucde/"><img src="https://img.shields.io/pypi/pyversions/ucde" alt="Supported Python versions"></a>
|
|
48
|
+
<a href="https://github.com/mqfarooqi1/ucde/actions/workflows/ci.yml"><img src="https://github.com/mqfarooqi1/ucde/actions/workflows/ci.yml/badge.svg" alt="CI status"></a>
|
|
49
|
+
<a href="https://github.com/mqfarooqi1/ucde/blob/main/LICENSE"><img src="https://img.shields.io/badge/licence-Apache--2.0-blue" alt="Apache-2.0 licence"></a>
|
|
50
|
+
<a href="#connect-an-ai-agent-mcp"><img src="https://img.shields.io/badge/MCP-read--only%20server-6E56CF" alt="Read-only MCP server"></a>
|
|
51
|
+
</p>
|
|
52
|
+
|
|
53
|
+
<p align="center"><a href="https://ucde-evidence.closedtiger256.chatgpt.site/">Website</a> · <a href="#quick-start">Quick start</a> · <a href="#connect-an-ai-agent-mcp">AI agents</a> · <a href="#guide">Guide</a> · <a href="https://github.com/mqfarooqi1/ucde/blob/main/CHANGELOG.md">Changelog</a></p>
|
|
54
|
+
|
|
55
|
+
UCDE is a local, append-only evidence ledger for experimental and computational research. Each observation keeps its source, locator, measurement context and complete revision history in one SQLite file. Corrections and retractions add revisions instead of overwriting, so a past search can be rerun exactly, cited and checked by someone else.
|
|
56
|
+
|
|
57
|
+
The first workflow uses plant breeding and phenotyping records. The examples also cover an assay-method record, a published wheat sensing dataset and two releases of the public JARVIS materials-simulation database. UCDE preserves independent observations even when they disagree.
|
|
58
|
+
|
|
59
|
+
## Why UCDE
|
|
60
|
+
|
|
61
|
+
Spreadsheets overwrite. Databases keep the latest value. Vector stores lose track of where an answer came from. UCDE is built for the questions those tools cannot answer.
|
|
62
|
+
|
|
63
|
+
| Question | How UCDE answers it |
|
|
64
|
+
|---|---|
|
|
65
|
+
| What did we know on 1 March? | `--known-at` reruns a search against the ledger as it stood at that instant. Recording time and observation time are separate, so a search can also bound when the measurement was taken. |
|
|
66
|
+
| Where did this number come from? | Every hit returns its source, locator, optional source SHA-256, revision number and ranking components. |
|
|
67
|
+
| What changed since the analysis? | Corrections, retractions and restorations are new revisions with their own provenance. Each write states the revision it expects, so one edit cannot silently replace another. Save a search as a packet, then compare or replay it later. |
|
|
68
|
+
| Can a reviewer check it without trusting us? | `ucde verify` audits the file. Checkpoints, an opt-in SHA-256 hash chain, portable archives and evidence packets produce receipts that anyone can check offline. |
|
|
69
|
+
| Can we share it in a standard format? | `ucde crate` packages history as an RO-Crate 1.2 with a W3C PROV-O provenance graph. |
|
|
70
|
+
| Can an AI agent use it safely? | A read-only MCP server exposes search and history. Its instructions tell agents to cite the source and to treat evidence text as data, never as instructions. |
|
|
71
|
+
|
|
72
|
+
The core is Python 3.11+ and SQLite: FTS5 for BM25 text search, plus optional dense vectors that you supply. It has no runtime dependencies and makes no network or model calls. The optional Ollama commands run only when you invoke them.
|
|
73
|
+
|
|
74
|
+
## Install
|
|
75
|
+
|
|
76
|
+
```shell
|
|
77
|
+
pip install ucde # Python library and ucde CLI, no dependencies
|
|
78
|
+
pip install "ucde[mcp]" # adds the MCP server for AI agents
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
UCDE needs SQLite with FTS5 and JSON functions, which the python.org, Homebrew and common Linux builds include. To try it without installing, run `uvx ucde --help` with [uv](https://docs.astral.sh/uv/).
|
|
82
|
+
|
|
83
|
+
## Quick start
|
|
84
|
+
|
|
85
|
+
Save a measurement as `plot-18.json`:
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{"id": "plot-18", "subject": "W-017", "variable": "plant height", "method": "ruler-v1", "scale": "cm",
|
|
89
|
+
"observed_at": "2025-09-05T05:30:00Z", "text": "W-017 measured 81 cm in plot 18.",
|
|
90
|
+
"source": "fieldbook-2025.csv", "locator": "row 18"}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Save its later correction as `plot-18-fixed.json`:
|
|
94
|
+
|
|
95
|
+
```json
|
|
96
|
+
{"id": "plot-18", "subject": "W-017", "variable": "plant height", "method": "ruler-v1", "scale": "cm",
|
|
97
|
+
"observed_at": "2025-09-05T05:30:00Z", "text": "W-017 measured 86 cm in plot 18 after re-measurement.",
|
|
98
|
+
"source": "fieldbook-2025-v2.csv", "locator": "row 18"}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Record both, then search the present and the past:
|
|
102
|
+
|
|
103
|
+
```shell
|
|
104
|
+
ucde --db evidence.db init
|
|
105
|
+
ucde --db evidence.db put plot-18.json # revision 1: note the recorded_at it prints
|
|
106
|
+
ucde --db evidence.db put plot-18-fixed.json --expected-revision 1 # revision 2: the correction
|
|
107
|
+
ucde --db evidence.db search "plant height" --subject W-017 # returns the 86 cm correction
|
|
108
|
+
ucde --db evidence.db search "plant height" --subject W-017 --known-at <recorded_at of revision 1>
|
|
109
|
+
ucde --db evidence.db history plot-18 # both revisions with their sources
|
|
110
|
+
ucde --db evidence.db verify # audit the file; exit 1 on any problem
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
The search with `--known-at` returns the original 81 cm revision and its source, `fieldbook-2025.csv`, because the correction was recorded later. Every command prints JSON, so the output works with `jq`, scripts and notebooks.
|
|
114
|
+
|
|
115
|
+
## Use it from Python
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
from ucde import Evidence, MemoryStore
|
|
119
|
+
|
|
120
|
+
store = MemoryStore("breeding-evidence.db")
|
|
121
|
+
observation = Evidence(
|
|
122
|
+
id="north-2025-plot-18", subject="W-017", variable="plant height",
|
|
123
|
+
method="ruler-v1", scale="cm", observed_at="2025-09-05T05:30:00Z",
|
|
124
|
+
text="W-017 measured 81 cm in plot 18.",
|
|
125
|
+
source="north-2025-fieldbook.csv", locator="csv-row:18",
|
|
126
|
+
context={"site": "north", "treatment": "rainfed", "trial": "2025"},
|
|
127
|
+
)
|
|
128
|
+
store.put(observation)
|
|
129
|
+
result = store.search("plant height", subject="W-017", method="ruler-v1",
|
|
130
|
+
scale="cm", context={"site": "north", "treatment": "rainfed"})
|
|
131
|
+
for hit in result.hits:
|
|
132
|
+
print(hit.revision.evidence.source, hit.revision.evidence.locator, hit.score)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The write above expects a new observation ID. Keep the returned revision and pass its `revision` to `store.put(corrected, expected_revision=...)` when correcting the observation. Use `known_at` to reconstruct which revision was available at a cutoff, and `observed_after` and `observed_before` to constrain when the measurement happened. Both observation endpoints are inclusive. `target_at` adds a soft date preference under adaptive ranking. Use `strategy="nearest"` with `target_at` when closeness in observation time should take priority over lexical relevance. See `ucde search --help` for the corresponding CLI options.
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
store.search(
|
|
139
|
+
"plant height", subject="W-017", method="ruler-v1", scale="cm",
|
|
140
|
+
observed_after="2025-09-01T00:00:00Z", observed_before="2025-09-08T00:00:00Z",
|
|
141
|
+
target_at="2025-09-05T00:00:00Z", strategy="nearest",
|
|
142
|
+
)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Source locators and optional checksums are provided by the caller. The engine does not resolve source content.
|
|
146
|
+
|
|
147
|
+
## Connect an AI agent (MCP)
|
|
148
|
+
|
|
149
|
+
`ucde[mcp]` adds a [Model Context Protocol](https://modelcontextprotocol.io) server with two read-only tools.
|
|
150
|
+
|
|
151
|
+
| Tool | Returns |
|
|
152
|
+
|---|---|
|
|
153
|
+
| `search_evidence` | Ranked hits with exact selectors, `known_at` time travel, observation-date bounds and full citations |
|
|
154
|
+
| `evidence_history` | Every retained revision of one observation, including corrections, retractions and restorations, in pages |
|
|
155
|
+
|
|
156
|
+
Point the server at an existing ledger by its absolute path. On Windows, write the path with forward slashes, such as `C:/research/evidence.db`. With [uv](https://docs.astral.sh/uv/) installed, the configurations below fetch everything else.
|
|
157
|
+
|
|
158
|
+
Claude Code:
|
|
159
|
+
|
|
160
|
+
```shell
|
|
161
|
+
claude mcp add ucde -- uvx --from "ucde[mcp]" ucde-mcp --db /absolute/path/evidence.db
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Claude Desktop, Cursor, Windsurf and other clients that read an `mcpServers` file:
|
|
165
|
+
|
|
166
|
+
```json
|
|
167
|
+
{
|
|
168
|
+
"mcpServers": {
|
|
169
|
+
"ucde": {
|
|
170
|
+
"command": "uvx",
|
|
171
|
+
"args": ["--from", "ucde[mcp]", "ucde-mcp", "--db", "/absolute/path/evidence.db"]
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
VS Code, in `.vscode/mcp.json`:
|
|
178
|
+
|
|
179
|
+
```json
|
|
180
|
+
{
|
|
181
|
+
"servers": {
|
|
182
|
+
"ucde": {
|
|
183
|
+
"type": "stdio",
|
|
184
|
+
"command": "uvx",
|
|
185
|
+
"args": ["--from", "ucde[mcp]", "ucde-mcp", "--db", "/absolute/path/evidence.db"]
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Without uv, run `pip install "ucde[mcp]"` and use `ucde-mcp --db /absolute/path/evidence.db` as the command. From 0.2.1, `ucde --db /absolute/path/evidence.db mcp` starts the same server.
|
|
192
|
+
|
|
193
|
+
The server opens the file read-only and refuses a file whose schema UCDE did not create. Tool errors do not echo paths or database details. The server uses the MCP Python SDK 2.3 and accepts both the initialize handshake (protocol 2025-11-25) and the per-request protocol (2026-07-28). Read the [threat model](https://github.com/mqfarooqi1/ucde/blob/main/security/THREAT_MODEL.md) before you open a store to an agent.
|
|
194
|
+
|
|
195
|
+
## Guide
|
|
196
|
+
|
|
197
|
+
### Load and replay dataset releases
|
|
198
|
+
|
|
199
|
+
Use `store.apply_batch(...)` to commit a complete set of changes as one event. Pass `EvidenceWrite` for new or corrected records and `EvidenceRetraction` for records that should cease to be active. Each change carries the current expected revision, with `0` for a new identifier. All revisions in a batch share one `recorded_at`. `store.get(id, known_at=cutoff)` returns the active revision by ID using the recording cutoff alone. Earlier revisions remain available through `store.history(id)`.
|
|
200
|
+
|
|
201
|
+
The [JARVIS release replay](https://github.com/mqfarooqi1/ucde/blob/main/benchmarks/real_data/README.md#replay-two-published-jarvis-releases) applies these operations to two checksummed public archives. Its recording clock uses each publisher release instant to reconstruct historical availability.
|
|
202
|
+
|
|
203
|
+
### Export a historical evidence packet
|
|
204
|
+
|
|
205
|
+
Use `ucde export` to save a scoped text search, its recording cutoff, and the exact results with citations and revision numbers. A collaborator can read the JSON and verify the packet offline. The cutoff is any ISO 8601 time with a UTC offset, such as the `recorded_at` of your latest write.
|
|
206
|
+
|
|
207
|
+
```shell
|
|
208
|
+
ucde --db breeding-evidence.db export "plant height" --subject W-017 --known-at <cutoff> --output height-packet.json
|
|
209
|
+
ucde verify-packet height-packet.json
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
The export prints a SHA-256 receipt. To compare a copy against a digest received separately, pass that digest to `ucde verify-packet` with `--expected-sha256`. The Python SDK also provides `export_packet` and `verify_packet`. [Public examples and attribution](https://github.com/mqfarooqi1/ucde/blob/main/examples/README.md#portable-packets-from-published-datasets).
|
|
213
|
+
|
|
214
|
+
#### Compare two packets
|
|
215
|
+
|
|
216
|
+
```shell
|
|
217
|
+
ucde compare earlier-packet.json later-packet.json
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
The report matches records by evidence ID and shows changes to the evidence, citation, revision, and ranking. It also shows differences in search settings and the effective observation cutoff for each packet. A record present in just one result can reflect the query, the result limit, or the ledger state. Supply `--before-sha256` and `--after-sha256` to check the files against digests received separately. The SDK equivalent is `compare_packets`.
|
|
221
|
+
|
|
222
|
+
#### Replay a packet against a ledger
|
|
223
|
+
|
|
224
|
+
```shell
|
|
225
|
+
ucde --db breeding-evidence.db replay height-packet.json
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Replay runs the saved query and selectors at the packet's recording cutoff. It opens the ledger read-only and reports whether the new result has the same digest. A difference report includes changes to returned records, citations, ranking, and search candidate counts. The command exits 0 for a match and 1 for a difference or invalid packet. To supply a separately obtained digest, use `--expected-sha256`. The SDK equivalent is `replay_packet`.
|
|
229
|
+
|
|
230
|
+
### Check a ledger
|
|
231
|
+
|
|
232
|
+
`ucde --db evidence.db verify` audits a file without changing it. It runs SQLite's integrity check, then confirms each ledger invariant against the stored payloads, for example that an observation's revisions are consecutive, that recording times stay in order, and that every search entry matches the payload it indexes. It prints a JSON report and exits 1 when it finds a problem, so it can gate a backup, a restore or a scheduled job. `MemoryStore.verify()` returns the same report in Python. Every open also refuses a file whose schema UCDE did not create, such as one that defines a trigger or view.
|
|
233
|
+
|
|
234
|
+
#### Save and check a ledger checkpoint
|
|
235
|
+
|
|
236
|
+
```shell
|
|
237
|
+
ucde --db evidence.db checkpoint # prints known_at and sha256
|
|
238
|
+
ucde --db evidence.db checkpoint --known-at <known_at> --expected-sha256 <sha256>
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Save the reported cutoff and SHA-256 separately from the ledger, for example in a lab notebook. Rechecking compares every retained revision through that cutoff, including retractions. Commits recorded after the cutoff preserve the checkpoint. A purge of covered history or a change to a covered citation produces a mismatch and exit code 1. The CLI opens the ledger read-only and returns the digest and counts. The Python SDK provides the same check through `MemoryStore.checkpoint()`.
|
|
242
|
+
|
|
243
|
+
#### Enable and verify a persistent ledger chain
|
|
244
|
+
|
|
245
|
+
```shell
|
|
246
|
+
ucde --db evidence.db enable-chain --output evidence-v3.db
|
|
247
|
+
ucde --db evidence-v3.db chain-head > trusted-head.json
|
|
248
|
+
ucde --db evidence-v3.db verify --head-file trusted-head.json
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
In Windows PowerShell 5.1, save the head with `| Set-Content -Encoding utf8 trusted-head.json` instead, because `>` in that shell writes UTF-16.
|
|
252
|
+
|
|
253
|
+
`enable-chain` audits and upgrades a new SQLite copy. The source remains the schema 2 backup when upgrading from schema 2. Save the chain head separately from the database. Verification checks the saved prefix and every commit that follows it, so later valid writes preserve the check and an older backup fails it. A purge retains opaque commitments and commit coordinates while removing the payload and nonce from the ledger. The SDK provides `MemoryStore.enable_chain()`, `chain_head()`, and `verify(expected_head=...)`. [Schema 3 format and migration](https://github.com/mqfarooqi1/ucde/blob/main/specifications/ledger-chaining-v3.md).
|
|
254
|
+
|
|
255
|
+
#### Export a portable history archive
|
|
256
|
+
|
|
257
|
+
```shell
|
|
258
|
+
ucde --db evidence.db archive --output evidence-history.jsonl # prints a receipt with its sha256
|
|
259
|
+
ucde verify-archive evidence-history.jsonl --expected-sha256 <sha256>
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
The archive contains the full stored payload for every retained revision through its recording cutoff, including earlier versions, retractions, and stored vectors. Use `--known-at` to select a specific cutoff. The archive bytes hash to the same SHA-256 as a checkpoint at that cutoff. A recipient can verify the file offline using the digest you saved separately. The verifier returns exit 1 if the digest differs or the archive is malformed. Python applications can use `MemoryStore.export_archive()` and `verify_archive()`.
|
|
263
|
+
|
|
264
|
+
#### Package an archive for research exchange
|
|
265
|
+
|
|
266
|
+
```shell
|
|
267
|
+
ucde crate evidence-history.jsonl --expected-sha256 <sha256> --output research-crate --name "Study evidence" --description "Retained measurement revisions" --date-published 2026-12-05 --license "Internal research use"
|
|
268
|
+
ucde verify-archive research-crate/history.jsonl --expected-sha256 <sha256>
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
`ucde crate` validates the archive before packaging it with its checkpoint receipt, RO-Crate metadata, and a JSON-LD provenance graph. The graph records source locators and digests, revision links, and recording and observation times. Supply the title, description, publication date, and licence or terms that apply to your package. The Python equivalent is `create_crate()`. [RO-Crate 1.2](https://www.researchobject.org/ro-crate/specification/1.2/) · [W3C PROV-O](https://www.w3.org/TR/prov-o/).
|
|
272
|
+
|
|
273
|
+
### Run from a source checkout
|
|
274
|
+
|
|
275
|
+
```shell
|
|
276
|
+
python -m pip install .
|
|
277
|
+
python examples/evidence_walkthrough.py
|
|
278
|
+
python examples/agicam_wheat.py --wheat spring --variety 9 --sensor AG13 --vi NDVI --through 2022-06-10
|
|
279
|
+
python -m unittest discover -s tests -v
|
|
280
|
+
python -m benchmarks.run_memory --output my-memory-benchmark.json
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
`python -m pip install .` can fetch the pinned build dependency when needed. If `build` and setuptools 81.0.0 are already available, build and install entirely offline with `python -m build --no-isolation --wheel` followed by `python -m pip install --no-index --no-deps --find-links dist ucde`. To run without installing, set `PYTHONPATH` to `python` and use `python -m ucde` as the CLI command. The walkthroughs use temporary databases. The AGIcam example returns the original CSV line and measurement context from a small published dataset excerpt. [Dataset and licence](https://zenodo.org/records/17970104).
|
|
284
|
+
|
|
285
|
+
### Optional integrations
|
|
286
|
+
|
|
287
|
+
- `ucde models` and `ucde generate --model <installed-model> --prompt "Example"` connect to an already running Ollama daemon on numeric loopback. `ucde.ollama.OllamaClient.embed` computes an embedding explicitly. Use one pinned embedding space for compatible vectors. The ledger and MCP server never send retrieved evidence to Ollama. Disable cloud features and block outbound connectivity in offline deployments. [Ollama FAQ](https://docs.ollama.com/faq).
|
|
288
|
+
- With Docker Compose, `docker compose run --rm ucde` initializes a named volume in an isolated container. Pass CLI arguments after `ucde` for subsequent runs. The image contains the core CLI only and builds using the Docker base image and the pinned build backend. CI builds it and round-trips evidence with no network and a read-only root file system.
|
|
289
|
+
|
|
290
|
+
## Project status
|
|
291
|
+
|
|
292
|
+
UCDE is alpha software for research evidence. It has no clinical workflow or enterprise service. Start with the [Phase 0 assessment](https://github.com/mqfarooqi1/ucde/blob/main/research/phase-0-assessment.md), [algorithm specification](https://github.com/mqfarooqi1/ucde/blob/main/specifications/evidence-memory-v1.md), and [benchmark](https://github.com/mqfarooqi1/ucde/blob/main/benchmarks/README.md). The [development status](https://github.com/mqfarooqi1/ucde/blob/main/DEVELOPMENT_STATUS.md) records verified results, current limits and the next research milestone, and the [roadmap](https://github.com/mqfarooqi1/ucde/blob/main/ROADMAP.md) lists what comes next. The [threat model](https://github.com/mqfarooqi1/ucde/blob/main/security/THREAT_MODEL.md) explains the local trust boundary. Use separate files and OS permissions for different principals.
|
|
293
|
+
|
|
294
|
+
## Contributing
|
|
295
|
+
|
|
296
|
+
Bug reports, research use cases and pull requests are welcome. Read the [contributing guide](https://github.com/mqfarooqi1/ucde/blob/main/CONTRIBUTING.md) and the [code of conduct](https://github.com/mqfarooqi1/ucde/blob/main/CODE_OF_CONDUCT.md). Report security problems privately as described in the [security policy](https://github.com/mqfarooqi1/ucde/blob/main/SECURITY.md). If UCDE is useful to you, a star on [GitHub](https://github.com/mqfarooqi1/ucde) helps other researchers find it.
|
|
297
|
+
|
|
298
|
+
## Citation and licence
|
|
299
|
+
|
|
300
|
+
To cite UCDE, use [CITATION.cff](https://github.com/mqfarooqi1/ucde/blob/main/CITATION.cff) or the "Cite this repository" button on GitHub. UCDE is licensed under Apache-2.0. See [LICENSE](https://github.com/mqfarooqi1/ucde/blob/main/LICENSE).
|
|
301
|
+
|
|
302
|
+
Created and maintained by [Muhammad Q Farooqi](https://github.com/mqfarooqi1).
|
ucde-0.2.1/README.md
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
<!-- mcp-name: io.github.mqfarooqi1/ucde -->
|
|
2
|
+
<p align="center"><a href="https://ucde-evidence.closedtiger256.chatgpt.site/"><img src="https://raw.githubusercontent.com/mqfarooqi1/ucde/main/docs/assets/ucde-logo.png" alt="UCDE logo" width="96" height="96"></a></p>
|
|
3
|
+
|
|
4
|
+
<h1 align="center">UCDE: Universal Cognitive Data Engine</h1>
|
|
5
|
+
|
|
6
|
+
<p align="center"><strong>Version control for research evidence.</strong> Search what was known at any past date, see where every answer came from, and give AI agents the same cited, read-only view.</p>
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
<a href="https://pypi.org/project/ucde/"><img src="https://img.shields.io/pypi/v/ucde" alt="PyPI version"></a>
|
|
10
|
+
<a href="https://pypi.org/project/ucde/"><img src="https://img.shields.io/pypi/pyversions/ucde" alt="Supported Python versions"></a>
|
|
11
|
+
<a href="https://github.com/mqfarooqi1/ucde/actions/workflows/ci.yml"><img src="https://github.com/mqfarooqi1/ucde/actions/workflows/ci.yml/badge.svg" alt="CI status"></a>
|
|
12
|
+
<a href="https://github.com/mqfarooqi1/ucde/blob/main/LICENSE"><img src="https://img.shields.io/badge/licence-Apache--2.0-blue" alt="Apache-2.0 licence"></a>
|
|
13
|
+
<a href="#connect-an-ai-agent-mcp"><img src="https://img.shields.io/badge/MCP-read--only%20server-6E56CF" alt="Read-only MCP server"></a>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p align="center"><a href="https://ucde-evidence.closedtiger256.chatgpt.site/">Website</a> · <a href="#quick-start">Quick start</a> · <a href="#connect-an-ai-agent-mcp">AI agents</a> · <a href="#guide">Guide</a> · <a href="https://github.com/mqfarooqi1/ucde/blob/main/CHANGELOG.md">Changelog</a></p>
|
|
17
|
+
|
|
18
|
+
UCDE is a local, append-only evidence ledger for experimental and computational research. Each observation keeps its source, locator, measurement context and complete revision history in one SQLite file. Corrections and retractions add revisions instead of overwriting, so a past search can be rerun exactly, cited and checked by someone else.
|
|
19
|
+
|
|
20
|
+
The first workflow uses plant breeding and phenotyping records. The examples also cover an assay-method record, a published wheat sensing dataset and two releases of the public JARVIS materials-simulation database. UCDE preserves independent observations even when they disagree.
|
|
21
|
+
|
|
22
|
+
## Why UCDE
|
|
23
|
+
|
|
24
|
+
Spreadsheets overwrite. Databases keep the latest value. Vector stores lose track of where an answer came from. UCDE is built for the questions those tools cannot answer.
|
|
25
|
+
|
|
26
|
+
| Question | How UCDE answers it |
|
|
27
|
+
|---|---|
|
|
28
|
+
| What did we know on 1 March? | `--known-at` reruns a search against the ledger as it stood at that instant. Recording time and observation time are separate, so a search can also bound when the measurement was taken. |
|
|
29
|
+
| Where did this number come from? | Every hit returns its source, locator, optional source SHA-256, revision number and ranking components. |
|
|
30
|
+
| What changed since the analysis? | Corrections, retractions and restorations are new revisions with their own provenance. Each write states the revision it expects, so one edit cannot silently replace another. Save a search as a packet, then compare or replay it later. |
|
|
31
|
+
| Can a reviewer check it without trusting us? | `ucde verify` audits the file. Checkpoints, an opt-in SHA-256 hash chain, portable archives and evidence packets produce receipts that anyone can check offline. |
|
|
32
|
+
| Can we share it in a standard format? | `ucde crate` packages history as an RO-Crate 1.2 with a W3C PROV-O provenance graph. |
|
|
33
|
+
| Can an AI agent use it safely? | A read-only MCP server exposes search and history. Its instructions tell agents to cite the source and to treat evidence text as data, never as instructions. |
|
|
34
|
+
|
|
35
|
+
The core is Python 3.11+ and SQLite: FTS5 for BM25 text search, plus optional dense vectors that you supply. It has no runtime dependencies and makes no network or model calls. The optional Ollama commands run only when you invoke them.
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
```shell
|
|
40
|
+
pip install ucde # Python library and ucde CLI, no dependencies
|
|
41
|
+
pip install "ucde[mcp]" # adds the MCP server for AI agents
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
UCDE needs SQLite with FTS5 and JSON functions, which the python.org, Homebrew and common Linux builds include. To try it without installing, run `uvx ucde --help` with [uv](https://docs.astral.sh/uv/).
|
|
45
|
+
|
|
46
|
+
## Quick start
|
|
47
|
+
|
|
48
|
+
Save a measurement as `plot-18.json`:
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{"id": "plot-18", "subject": "W-017", "variable": "plant height", "method": "ruler-v1", "scale": "cm",
|
|
52
|
+
"observed_at": "2025-09-05T05:30:00Z", "text": "W-017 measured 81 cm in plot 18.",
|
|
53
|
+
"source": "fieldbook-2025.csv", "locator": "row 18"}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Save its later correction as `plot-18-fixed.json`:
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{"id": "plot-18", "subject": "W-017", "variable": "plant height", "method": "ruler-v1", "scale": "cm",
|
|
60
|
+
"observed_at": "2025-09-05T05:30:00Z", "text": "W-017 measured 86 cm in plot 18 after re-measurement.",
|
|
61
|
+
"source": "fieldbook-2025-v2.csv", "locator": "row 18"}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Record both, then search the present and the past:
|
|
65
|
+
|
|
66
|
+
```shell
|
|
67
|
+
ucde --db evidence.db init
|
|
68
|
+
ucde --db evidence.db put plot-18.json # revision 1: note the recorded_at it prints
|
|
69
|
+
ucde --db evidence.db put plot-18-fixed.json --expected-revision 1 # revision 2: the correction
|
|
70
|
+
ucde --db evidence.db search "plant height" --subject W-017 # returns the 86 cm correction
|
|
71
|
+
ucde --db evidence.db search "plant height" --subject W-017 --known-at <recorded_at of revision 1>
|
|
72
|
+
ucde --db evidence.db history plot-18 # both revisions with their sources
|
|
73
|
+
ucde --db evidence.db verify # audit the file; exit 1 on any problem
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The search with `--known-at` returns the original 81 cm revision and its source, `fieldbook-2025.csv`, because the correction was recorded later. Every command prints JSON, so the output works with `jq`, scripts and notebooks.
|
|
77
|
+
|
|
78
|
+
## Use it from Python
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from ucde import Evidence, MemoryStore
|
|
82
|
+
|
|
83
|
+
store = MemoryStore("breeding-evidence.db")
|
|
84
|
+
observation = Evidence(
|
|
85
|
+
id="north-2025-plot-18", subject="W-017", variable="plant height",
|
|
86
|
+
method="ruler-v1", scale="cm", observed_at="2025-09-05T05:30:00Z",
|
|
87
|
+
text="W-017 measured 81 cm in plot 18.",
|
|
88
|
+
source="north-2025-fieldbook.csv", locator="csv-row:18",
|
|
89
|
+
context={"site": "north", "treatment": "rainfed", "trial": "2025"},
|
|
90
|
+
)
|
|
91
|
+
store.put(observation)
|
|
92
|
+
result = store.search("plant height", subject="W-017", method="ruler-v1",
|
|
93
|
+
scale="cm", context={"site": "north", "treatment": "rainfed"})
|
|
94
|
+
for hit in result.hits:
|
|
95
|
+
print(hit.revision.evidence.source, hit.revision.evidence.locator, hit.score)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The write above expects a new observation ID. Keep the returned revision and pass its `revision` to `store.put(corrected, expected_revision=...)` when correcting the observation. Use `known_at` to reconstruct which revision was available at a cutoff, and `observed_after` and `observed_before` to constrain when the measurement happened. Both observation endpoints are inclusive. `target_at` adds a soft date preference under adaptive ranking. Use `strategy="nearest"` with `target_at` when closeness in observation time should take priority over lexical relevance. See `ucde search --help` for the corresponding CLI options.
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
store.search(
|
|
102
|
+
"plant height", subject="W-017", method="ruler-v1", scale="cm",
|
|
103
|
+
observed_after="2025-09-01T00:00:00Z", observed_before="2025-09-08T00:00:00Z",
|
|
104
|
+
target_at="2025-09-05T00:00:00Z", strategy="nearest",
|
|
105
|
+
)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Source locators and optional checksums are provided by the caller. The engine does not resolve source content.
|
|
109
|
+
|
|
110
|
+
## Connect an AI agent (MCP)
|
|
111
|
+
|
|
112
|
+
`ucde[mcp]` adds a [Model Context Protocol](https://modelcontextprotocol.io) server with two read-only tools.
|
|
113
|
+
|
|
114
|
+
| Tool | Returns |
|
|
115
|
+
|---|---|
|
|
116
|
+
| `search_evidence` | Ranked hits with exact selectors, `known_at` time travel, observation-date bounds and full citations |
|
|
117
|
+
| `evidence_history` | Every retained revision of one observation, including corrections, retractions and restorations, in pages |
|
|
118
|
+
|
|
119
|
+
Point the server at an existing ledger by its absolute path. On Windows, write the path with forward slashes, such as `C:/research/evidence.db`. With [uv](https://docs.astral.sh/uv/) installed, the configurations below fetch everything else.
|
|
120
|
+
|
|
121
|
+
Claude Code:
|
|
122
|
+
|
|
123
|
+
```shell
|
|
124
|
+
claude mcp add ucde -- uvx --from "ucde[mcp]" ucde-mcp --db /absolute/path/evidence.db
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Claude Desktop, Cursor, Windsurf and other clients that read an `mcpServers` file:
|
|
128
|
+
|
|
129
|
+
```json
|
|
130
|
+
{
|
|
131
|
+
"mcpServers": {
|
|
132
|
+
"ucde": {
|
|
133
|
+
"command": "uvx",
|
|
134
|
+
"args": ["--from", "ucde[mcp]", "ucde-mcp", "--db", "/absolute/path/evidence.db"]
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
VS Code, in `.vscode/mcp.json`:
|
|
141
|
+
|
|
142
|
+
```json
|
|
143
|
+
{
|
|
144
|
+
"servers": {
|
|
145
|
+
"ucde": {
|
|
146
|
+
"type": "stdio",
|
|
147
|
+
"command": "uvx",
|
|
148
|
+
"args": ["--from", "ucde[mcp]", "ucde-mcp", "--db", "/absolute/path/evidence.db"]
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Without uv, run `pip install "ucde[mcp]"` and use `ucde-mcp --db /absolute/path/evidence.db` as the command. From 0.2.1, `ucde --db /absolute/path/evidence.db mcp` starts the same server.
|
|
155
|
+
|
|
156
|
+
The server opens the file read-only and refuses a file whose schema UCDE did not create. Tool errors do not echo paths or database details. The server uses the MCP Python SDK 2.3 and accepts both the initialize handshake (protocol 2025-11-25) and the per-request protocol (2026-07-28). Read the [threat model](https://github.com/mqfarooqi1/ucde/blob/main/security/THREAT_MODEL.md) before you open a store to an agent.
|
|
157
|
+
|
|
158
|
+
## Guide
|
|
159
|
+
|
|
160
|
+
### Load and replay dataset releases
|
|
161
|
+
|
|
162
|
+
Use `store.apply_batch(...)` to commit a complete set of changes as one event. Pass `EvidenceWrite` for new or corrected records and `EvidenceRetraction` for records that should cease to be active. Each change carries the current expected revision, with `0` for a new identifier. All revisions in a batch share one `recorded_at`. `store.get(id, known_at=cutoff)` returns the active revision by ID using the recording cutoff alone. Earlier revisions remain available through `store.history(id)`.
|
|
163
|
+
|
|
164
|
+
The [JARVIS release replay](https://github.com/mqfarooqi1/ucde/blob/main/benchmarks/real_data/README.md#replay-two-published-jarvis-releases) applies these operations to two checksummed public archives. Its recording clock uses each publisher release instant to reconstruct historical availability.
|
|
165
|
+
|
|
166
|
+
### Export a historical evidence packet
|
|
167
|
+
|
|
168
|
+
Use `ucde export` to save a scoped text search, its recording cutoff, and the exact results with citations and revision numbers. A collaborator can read the JSON and verify the packet offline. The cutoff is any ISO 8601 time with a UTC offset, such as the `recorded_at` of your latest write.
|
|
169
|
+
|
|
170
|
+
```shell
|
|
171
|
+
ucde --db breeding-evidence.db export "plant height" --subject W-017 --known-at <cutoff> --output height-packet.json
|
|
172
|
+
ucde verify-packet height-packet.json
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
The export prints a SHA-256 receipt. To compare a copy against a digest received separately, pass that digest to `ucde verify-packet` with `--expected-sha256`. The Python SDK also provides `export_packet` and `verify_packet`. [Public examples and attribution](https://github.com/mqfarooqi1/ucde/blob/main/examples/README.md#portable-packets-from-published-datasets).
|
|
176
|
+
|
|
177
|
+
#### Compare two packets
|
|
178
|
+
|
|
179
|
+
```shell
|
|
180
|
+
ucde compare earlier-packet.json later-packet.json
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
The report matches records by evidence ID and shows changes to the evidence, citation, revision, and ranking. It also shows differences in search settings and the effective observation cutoff for each packet. A record present in just one result can reflect the query, the result limit, or the ledger state. Supply `--before-sha256` and `--after-sha256` to check the files against digests received separately. The SDK equivalent is `compare_packets`.
|
|
184
|
+
|
|
185
|
+
#### Replay a packet against a ledger
|
|
186
|
+
|
|
187
|
+
```shell
|
|
188
|
+
ucde --db breeding-evidence.db replay height-packet.json
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Replay runs the saved query and selectors at the packet's recording cutoff. It opens the ledger read-only and reports whether the new result has the same digest. A difference report includes changes to returned records, citations, ranking, and search candidate counts. The command exits 0 for a match and 1 for a difference or invalid packet. To supply a separately obtained digest, use `--expected-sha256`. The SDK equivalent is `replay_packet`.
|
|
192
|
+
|
|
193
|
+
### Check a ledger
|
|
194
|
+
|
|
195
|
+
`ucde --db evidence.db verify` audits a file without changing it. It runs SQLite's integrity check, then confirms each ledger invariant against the stored payloads, for example that an observation's revisions are consecutive, that recording times stay in order, and that every search entry matches the payload it indexes. It prints a JSON report and exits 1 when it finds a problem, so it can gate a backup, a restore or a scheduled job. `MemoryStore.verify()` returns the same report in Python. Every open also refuses a file whose schema UCDE did not create, such as one that defines a trigger or view.
|
|
196
|
+
|
|
197
|
+
#### Save and check a ledger checkpoint
|
|
198
|
+
|
|
199
|
+
```shell
|
|
200
|
+
ucde --db evidence.db checkpoint # prints known_at and sha256
|
|
201
|
+
ucde --db evidence.db checkpoint --known-at <known_at> --expected-sha256 <sha256>
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Save the reported cutoff and SHA-256 separately from the ledger, for example in a lab notebook. Rechecking compares every retained revision through that cutoff, including retractions. Commits recorded after the cutoff preserve the checkpoint. A purge of covered history or a change to a covered citation produces a mismatch and exit code 1. The CLI opens the ledger read-only and returns the digest and counts. The Python SDK provides the same check through `MemoryStore.checkpoint()`.
|
|
205
|
+
|
|
206
|
+
#### Enable and verify a persistent ledger chain
|
|
207
|
+
|
|
208
|
+
```shell
|
|
209
|
+
ucde --db evidence.db enable-chain --output evidence-v3.db
|
|
210
|
+
ucde --db evidence-v3.db chain-head > trusted-head.json
|
|
211
|
+
ucde --db evidence-v3.db verify --head-file trusted-head.json
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
In Windows PowerShell 5.1, save the head with `| Set-Content -Encoding utf8 trusted-head.json` instead, because `>` in that shell writes UTF-16.
|
|
215
|
+
|
|
216
|
+
`enable-chain` audits and upgrades a new SQLite copy. The source remains the schema 2 backup when upgrading from schema 2. Save the chain head separately from the database. Verification checks the saved prefix and every commit that follows it, so later valid writes preserve the check and an older backup fails it. A purge retains opaque commitments and commit coordinates while removing the payload and nonce from the ledger. The SDK provides `MemoryStore.enable_chain()`, `chain_head()`, and `verify(expected_head=...)`. [Schema 3 format and migration](https://github.com/mqfarooqi1/ucde/blob/main/specifications/ledger-chaining-v3.md).
|
|
217
|
+
|
|
218
|
+
#### Export a portable history archive
|
|
219
|
+
|
|
220
|
+
```shell
|
|
221
|
+
ucde --db evidence.db archive --output evidence-history.jsonl # prints a receipt with its sha256
|
|
222
|
+
ucde verify-archive evidence-history.jsonl --expected-sha256 <sha256>
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
The archive contains the full stored payload for every retained revision through its recording cutoff, including earlier versions, retractions, and stored vectors. Use `--known-at` to select a specific cutoff. The archive bytes hash to the same SHA-256 as a checkpoint at that cutoff. A recipient can verify the file offline using the digest you saved separately. The verifier returns exit 1 if the digest differs or the archive is malformed. Python applications can use `MemoryStore.export_archive()` and `verify_archive()`.
|
|
226
|
+
|
|
227
|
+
#### Package an archive for research exchange
|
|
228
|
+
|
|
229
|
+
```shell
|
|
230
|
+
ucde crate evidence-history.jsonl --expected-sha256 <sha256> --output research-crate --name "Study evidence" --description "Retained measurement revisions" --date-published 2026-12-05 --license "Internal research use"
|
|
231
|
+
ucde verify-archive research-crate/history.jsonl --expected-sha256 <sha256>
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
`ucde crate` validates the archive before packaging it with its checkpoint receipt, RO-Crate metadata, and a JSON-LD provenance graph. The graph records source locators and digests, revision links, and recording and observation times. Supply the title, description, publication date, and licence or terms that apply to your package. The Python equivalent is `create_crate()`. [RO-Crate 1.2](https://www.researchobject.org/ro-crate/specification/1.2/) · [W3C PROV-O](https://www.w3.org/TR/prov-o/).
|
|
235
|
+
|
|
236
|
+
### Run from a source checkout
|
|
237
|
+
|
|
238
|
+
```shell
|
|
239
|
+
python -m pip install .
|
|
240
|
+
python examples/evidence_walkthrough.py
|
|
241
|
+
python examples/agicam_wheat.py --wheat spring --variety 9 --sensor AG13 --vi NDVI --through 2022-06-10
|
|
242
|
+
python -m unittest discover -s tests -v
|
|
243
|
+
python -m benchmarks.run_memory --output my-memory-benchmark.json
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
`python -m pip install .` can fetch the pinned build dependency when needed. If `build` and setuptools 81.0.0 are already available, build and install entirely offline with `python -m build --no-isolation --wheel` followed by `python -m pip install --no-index --no-deps --find-links dist ucde`. To run without installing, set `PYTHONPATH` to `python` and use `python -m ucde` as the CLI command. The walkthroughs use temporary databases. The AGIcam example returns the original CSV line and measurement context from a small published dataset excerpt. [Dataset and licence](https://zenodo.org/records/17970104).
|
|
247
|
+
|
|
248
|
+
### Optional integrations
|
|
249
|
+
|
|
250
|
+
- `ucde models` and `ucde generate --model <installed-model> --prompt "Example"` connect to an already running Ollama daemon on numeric loopback. `ucde.ollama.OllamaClient.embed` computes an embedding explicitly. Use one pinned embedding space for compatible vectors. The ledger and MCP server never send retrieved evidence to Ollama. Disable cloud features and block outbound connectivity in offline deployments. [Ollama FAQ](https://docs.ollama.com/faq).
|
|
251
|
+
- With Docker Compose, `docker compose run --rm ucde` initializes a named volume in an isolated container. Pass CLI arguments after `ucde` for subsequent runs. The image contains the core CLI only and builds using the Docker base image and the pinned build backend. CI builds it and round-trips evidence with no network and a read-only root file system.
|
|
252
|
+
|
|
253
|
+
## Project status
|
|
254
|
+
|
|
255
|
+
UCDE is alpha software for research evidence. It has no clinical workflow or enterprise service. Start with the [Phase 0 assessment](https://github.com/mqfarooqi1/ucde/blob/main/research/phase-0-assessment.md), [algorithm specification](https://github.com/mqfarooqi1/ucde/blob/main/specifications/evidence-memory-v1.md), and [benchmark](https://github.com/mqfarooqi1/ucde/blob/main/benchmarks/README.md). The [development status](https://github.com/mqfarooqi1/ucde/blob/main/DEVELOPMENT_STATUS.md) records verified results, current limits and the next research milestone, and the [roadmap](https://github.com/mqfarooqi1/ucde/blob/main/ROADMAP.md) lists what comes next. The [threat model](https://github.com/mqfarooqi1/ucde/blob/main/security/THREAT_MODEL.md) explains the local trust boundary. Use separate files and OS permissions for different principals.
|
|
256
|
+
|
|
257
|
+
## Contributing
|
|
258
|
+
|
|
259
|
+
Bug reports, research use cases and pull requests are welcome. Read the [contributing guide](https://github.com/mqfarooqi1/ucde/blob/main/CONTRIBUTING.md) and the [code of conduct](https://github.com/mqfarooqi1/ucde/blob/main/CODE_OF_CONDUCT.md). Report security problems privately as described in the [security policy](https://github.com/mqfarooqi1/ucde/blob/main/SECURITY.md). If UCDE is useful to you, a star on [GitHub](https://github.com/mqfarooqi1/ucde) helps other researchers find it.
|
|
260
|
+
|
|
261
|
+
## Citation and licence
|
|
262
|
+
|
|
263
|
+
To cite UCDE, use [CITATION.cff](https://github.com/mqfarooqi1/ucde/blob/main/CITATION.cff) or the "Cite this repository" button on GitHub. UCDE is licensed under Apache-2.0. See [LICENSE](https://github.com/mqfarooqi1/ucde/blob/main/LICENSE).
|
|
264
|
+
|
|
265
|
+
Created and maintained by [Muhammad Q Farooqi](https://github.com/mqfarooqi1).
|
|
@@ -5,15 +5,21 @@ build-backend = "setuptools.build_meta"
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "ucde"
|
|
7
7
|
dynamic = ["version"]
|
|
8
|
-
description = "
|
|
8
|
+
description = "Version-controlled research evidence: search what was known at any past date, with citations, verifiable history and a read-only MCP server"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
11
11
|
license = "Apache-2.0"
|
|
12
12
|
license-files = ["LICENSE"]
|
|
13
13
|
authors = [{ name = "Muhammad Q Farooqi" }]
|
|
14
|
-
keywords = [
|
|
14
|
+
keywords = [
|
|
15
|
+
"research data", "provenance", "evidence retrieval", "reproducibility", "audit trail", "bitemporal",
|
|
16
|
+
"time travel", "hash chain", "ro-crate", "w3c-prov", "plant breeding", "phenotyping", "sqlite", "fts5",
|
|
17
|
+
"bm25", "mcp", "model context protocol", "ai agents", "agent memory",
|
|
18
|
+
]
|
|
15
19
|
classifiers = [
|
|
16
20
|
"Development Status :: 3 - Alpha",
|
|
21
|
+
"Environment :: Console",
|
|
22
|
+
"Intended Audience :: Developers",
|
|
17
23
|
"Intended Audience :: Science/Research",
|
|
18
24
|
"Operating System :: OS Independent",
|
|
19
25
|
"Programming Language :: Python :: 3",
|
|
@@ -24,13 +30,19 @@ classifiers = [
|
|
|
24
30
|
"Programming Language :: Python :: 3.14",
|
|
25
31
|
"Programming Language :: Python :: 3.15",
|
|
26
32
|
"Topic :: Database",
|
|
33
|
+
"Topic :: Database :: Database Engines/Servers",
|
|
27
34
|
"Topic :: Scientific/Engineering",
|
|
35
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
36
|
+
"Topic :: Scientific/Engineering :: Information Analysis",
|
|
28
37
|
"Typing :: Typed",
|
|
29
38
|
]
|
|
30
39
|
dependencies = []
|
|
31
40
|
|
|
32
41
|
[project.urls]
|
|
42
|
+
Homepage = "https://ucde-evidence.closedtiger256.chatgpt.site/"
|
|
43
|
+
Documentation = "https://github.com/mqfarooqi1/ucde#guide"
|
|
33
44
|
Repository = "https://github.com/mqfarooqi1/ucde"
|
|
45
|
+
Issues = "https://github.com/mqfarooqi1/ucde/issues"
|
|
34
46
|
Changelog = "https://github.com/mqfarooqi1/ucde/blob/main/CHANGELOG.md"
|
|
35
47
|
|
|
36
48
|
[project.optional-dependencies]
|
|
@@ -10,7 +10,7 @@ from .model import (
|
|
|
10
10
|
from .packet import compare_packets, export_packet, replay_packet, verify_packet
|
|
11
11
|
from .store import MemoryStore
|
|
12
12
|
|
|
13
|
-
__version__ = "0.2.
|
|
13
|
+
__version__ = "0.2.1"
|
|
14
14
|
|
|
15
15
|
__all__ = [
|
|
16
16
|
"ConflictError", "Evidence", "EvidenceRetraction", "EvidenceWrite", "LedgerCheckpoint", "LedgerHead", "MemoryStore",
|