robo-cortex 0.4.2__tar.gz → 0.5.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.
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/CHANGELOG.md +21 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/PKG-INFO +6 -3
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/README.md +5 -2
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/__init__.py +1 -1
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/cli/_common.py +21 -1
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/cli/commands/evidence.py +11 -14
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/cli/commands/link.py +8 -4
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/cli/commands/list_cmd.py +11 -3
- robo_cortex-0.5.0/src/robo_cortex/cli/commands/record.py +179 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/cli/commands/retrieve.py +6 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/cli/commands/search.py +10 -2
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/cli/commands/show.py +2 -2
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/cli/commands/status.py +5 -4
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/core/errors.py +4 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/core/evidence.py +50 -1
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/core/memory.py +40 -14
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/core/retrieve.py +10 -8
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/core/store.py +38 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/sdk.py +47 -19
- robo_cortex-0.5.0/tests/test_cli_global_no_repo.py +151 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_cli_scope_b.py +56 -9
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_evidence.py +47 -2
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_mcp_contracts.py +25 -8
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_scope_b.py +69 -14
- robo_cortex-0.5.0/tests/test_sdk_global_no_repo.py +50 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_smoke.py +1 -1
- robo_cortex-0.4.2/src/robo_cortex/cli/commands/record.py +0 -156
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/.gitignore +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/LICENSE +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/pyproject.toml +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/schema.sql +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/cli/__init__.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/cli/__main__.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/cli/_output.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/cli/app.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/cli/commands/__init__.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/cli/commands/affected.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/cli/commands/completion.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/cli/commands/hooks.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/cli/commands/init.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/cli/commands/mcp.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/cli/commands/transfer.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/core/__init__.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/core/assumptions.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/core/db.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/core/git.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/core/hooks.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/core/init.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/core/invalidate.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/core/lifecycle.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/core/semantic.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/core/text.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/core/transfer.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/gitea.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/mcp_server.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/migrations/0001_init.sql +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/migrations/0002_add_usage_tracking.sql +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/src/robo_cortex/migrations/0003_add_meta_table.sql +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/__init__.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/conftest.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/fixtures.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_add_path.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_affected.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_assumptions.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_cli_affected.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_cli_init.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_cli_lifecycle.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_cli_record.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_cli_retrieve.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_completion.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_curation.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_db.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_gitea.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_hooks.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_init.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_invalidate.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_lifecycle.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_mcp_stdio.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_memory.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_output.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_record_batch.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_retrieve.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_reverify.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_sdk.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_search.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_semantic.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_transfer.py +0 -0
- {robo_cortex-0.4.2 → robo_cortex-0.5.0}/tests/test_update_path.py +0 -0
|
@@ -4,6 +4,27 @@ All notable changes to this project are documented here. Format loosely follows
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.5.0] — 2026-08-03
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **Global-scope commands no longer require a local repo store.** `show`, `search`, `retrieve`, `status`, `link`, `evidence add`/`verify`, `list`, and `record --scope global` used to unconditionally call `open_store()` first — hard-failing with "not inside a git repository" (or "run init first") even when the operation only ever touched `~/.cortex/global.db`, which is repo-independent by construction (ARCHITECTURE.md §2). In practice this meant a purely global lookup (`roco show <global-id>`) only worked if you happened to be standing inside *some* already-initialized repo — any one would do, but finding one by trial and error was real, reported friction. These commands now resolve the repo store lazily and fall back to global-only when none is available; `--scope repo` explicitly requested with no repo store still fails, now with a clear, actionable message (`no repo store available (not inside a git repo, or 'robo-cortex init' never ran there) -- pass --repo, or drop --scope repo to also check the global store`) instead of either crashing or silently returning nothing.
|
|
12
|
+
- **`record --scope global`** specifically no longer resolves a repo at all (not even lazily) — global records can't carry `--path` (already validated), so `repo_root` was accepted but never actually used for that branch. `roco record --scope global ...` now works from anywhere, including outside any git repo entirely.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- **Character limits in `record --help`.** `--statement` (500), `--why` (300), and `--assumptions` (500) previously enforced their limits only at write time, with no hint in `--help` — the only way to learn the ceiling was to hit the `ValidationError` and shorten. Now documented inline.
|
|
17
|
+
|
|
18
|
+
## [0.4.3] — 2026-07-31
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- **Silent wrong-store mutation on id collision.** Repo-local and global stores are independent autoincrement sequences, so a repo memory and a global memory can share the same numeric id. `roco status`/`link`/`evidence verify` (and the SDK/MCP equivalents), when called without `--scope`, used to silently pick whichever store hit first (local, by convention) — so e.g. `roco status 10 activate` could flip the wrong, unrelated memory to `active` with no error and no indication anything was off. `find_memory_store`/the new `find_evidence_store` now detect the collision and raise a clear `id N exists in both repo and global stores -- pass --scope repo or --scope global to disambiguate` error instead of guessing. `status`/`link` also now echo which store they acted on (`Memory 10 (global) -> active`) so a resolved-but-unintended target is visible immediately. Found live during normal usage.
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- **Global store id partitioning.** New global memories/evidence/links now start at id 1,000,000,000+ (bumped in place, no renumbering of existing rows) so future ids can no longer collide with any repo-local store's ids — the same bug class above, closed structurally going forward. Ids assigned before this change can still collide with existing repo-local ids; the collision-detection fix above is what catches those.
|
|
27
|
+
|
|
7
28
|
## [0.4.2] — 2026-07-26
|
|
8
29
|
|
|
9
30
|
### Changed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: robo-cortex
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: Long-term memory system for LLM coding agents working inside a Git repository
|
|
5
5
|
Project-URL: Homepage, https://robotel.top
|
|
6
6
|
Project-URL: Repository, https://github.com/robotel-limited/robo-cortex
|
|
@@ -36,12 +36,13 @@ Description-Content-Type: text/markdown
|
|
|
36
36
|
[](https://opensource.org/licenses/MIT)
|
|
37
37
|
[](https://smithery.ai/servers/robotel-top/robo-cortex)
|
|
38
38
|
[](https://glama.ai/mcp/servers/robotel-limited/robo-cortex)
|
|
39
|
+
[](https://doi.org/10.5281/zenodo.21610869)
|
|
39
40
|
|
|
40
41
|
[](https://glama.ai/mcp/servers/robotel-limited/robo-cortex)
|
|
41
42
|
|
|
42
43
|
**Git-aware knowledge integrity for AI coding agents.**
|
|
43
44
|
|
|
44
|
-
Your AI agent debugs a bug, learns the lesson, and forgets it by next week — or worse, keeps citing a "lesson" that the code has since made false. robo-cortex is a local knowledge base built for that specific failure mode: memories are anchored to git blob hashes, so when the code they're about changes, the memory is automatically flagged for review instead of being silently trusted or silently lost.
|
|
45
|
+
Your AI agent debugs a bug, learns the lesson, and forgets it by next week — or worse, keeps citing a "lesson" that the code has since made false. robo-cortex is a local knowledge base built for that specific failure mode: memories are anchored to git blob hashes, so when the code they're about changes, the memory is automatically flagged for review instead of being silently trusted or silently lost. In other words: **drift detection and stale-memory detection for AI agent memory**, done deterministically from git history — not an LLM guess, not an embedding-similarity heuristic.
|
|
45
46
|
|
|
46
47
|
---
|
|
47
48
|
|
|
@@ -49,7 +50,7 @@ Your AI agent debugs a bug, learns the lesson, and forgets it by next week — o
|
|
|
49
50
|
|
|
50
51
|
Most agent-memory tools are embeddings + a vector database + a cloud dependency. robo-cortex is deliberately none of that. Four things it does that a generic key-value memory store doesn't:
|
|
51
52
|
|
|
52
|
-
1. **Git-aware staleness detection.** Every memory can link to specific file paths, captured by git blob hash at record time. When the linked code changes, the memory is automatically flagged `needs_review` on the next `retrieve`/`search`/`affected` call — and a committed revert automatically heals it back. The healing requires three conditions: (a) the revert must be **committed** (git blob hash must match HEAD again), (b) the memory must have been flagged by the system (not manually via `change_status`), and (c) you must run a lazy trigger (`retrieve`/`search`/`affected`) after the revert to scan for changes.
|
|
53
|
+
1. **Git-aware staleness (drift) detection.** Every memory can link to specific file paths, captured by git blob hash at record time. When the linked code changes, the memory is automatically flagged `needs_review` on the next `retrieve`/`search`/`affected` call — and a committed revert automatically heals it back. The healing requires three conditions: (a) the revert must be **committed** (git blob hash must match HEAD again), (b) the memory must have been flagged by the system (not manually via `change_status`), and (c) you must run a lazy trigger (`retrieve`/`search`/`affected`) after the revert to scan for changes. Few memory tools tie themselves to your actual code's history this deterministically — no embedding similarity, no LLM judgment call, just a git blob hash matching or not.
|
|
53
54
|
2. **Evidence, not vibes.** Memories can carry attached evidence (test output, a commit, a re-runnable command) with a mechanically computed strength — not a judgment call. A `provisional` memory only becomes `active` once real evidence backs it, or a human explicitly promotes it.
|
|
54
55
|
3. **Zero dependencies, fully local.** Pure stdlib + SQLite (FTS5 for search). No embeddings, no API keys, no network calls unless you explicitly configure Gitea evidence verification. `.cortex/memory.db` is just a file — inspect it with `sqlite3` any time.
|
|
55
56
|
4. **A real lifecycle with an audit trail.** Every status change (`active` → `superseded` → `archived`, etc.) requires a `--reason`, permanently recorded. Nothing disappears silently; wrong lessons are marked `invalidated`, not deleted.
|
|
@@ -123,6 +124,8 @@ roco record --type lesson --scope global \
|
|
|
123
124
|
--assumptions "css grid gap safari"
|
|
124
125
|
```
|
|
125
126
|
|
|
127
|
+
Global-scope commands (`record --scope global`, `show`, `search`, `status`, `link`, `evidence`, `list`) work from anywhere, including outside any git repository — the global store (`~/.cortex/global.db`) isn't tied to a project. `retrieve` is the one exception: it's local-repo-aware by design, so it still requires an initialized repo.
|
|
128
|
+
|
|
126
129
|
### Enable enforcement (recommended)
|
|
127
130
|
|
|
128
131
|
```bash
|
|
@@ -7,12 +7,13 @@
|
|
|
7
7
|
[](https://opensource.org/licenses/MIT)
|
|
8
8
|
[](https://smithery.ai/servers/robotel-top/robo-cortex)
|
|
9
9
|
[](https://glama.ai/mcp/servers/robotel-limited/robo-cortex)
|
|
10
|
+
[](https://doi.org/10.5281/zenodo.21610869)
|
|
10
11
|
|
|
11
12
|
[](https://glama.ai/mcp/servers/robotel-limited/robo-cortex)
|
|
12
13
|
|
|
13
14
|
**Git-aware knowledge integrity for AI coding agents.**
|
|
14
15
|
|
|
15
|
-
Your AI agent debugs a bug, learns the lesson, and forgets it by next week — or worse, keeps citing a "lesson" that the code has since made false. robo-cortex is a local knowledge base built for that specific failure mode: memories are anchored to git blob hashes, so when the code they're about changes, the memory is automatically flagged for review instead of being silently trusted or silently lost.
|
|
16
|
+
Your AI agent debugs a bug, learns the lesson, and forgets it by next week — or worse, keeps citing a "lesson" that the code has since made false. robo-cortex is a local knowledge base built for that specific failure mode: memories are anchored to git blob hashes, so when the code they're about changes, the memory is automatically flagged for review instead of being silently trusted or silently lost. In other words: **drift detection and stale-memory detection for AI agent memory**, done deterministically from git history — not an LLM guess, not an embedding-similarity heuristic.
|
|
16
17
|
|
|
17
18
|
---
|
|
18
19
|
|
|
@@ -20,7 +21,7 @@ Your AI agent debugs a bug, learns the lesson, and forgets it by next week — o
|
|
|
20
21
|
|
|
21
22
|
Most agent-memory tools are embeddings + a vector database + a cloud dependency. robo-cortex is deliberately none of that. Four things it does that a generic key-value memory store doesn't:
|
|
22
23
|
|
|
23
|
-
1. **Git-aware staleness detection.** Every memory can link to specific file paths, captured by git blob hash at record time. When the linked code changes, the memory is automatically flagged `needs_review` on the next `retrieve`/`search`/`affected` call — and a committed revert automatically heals it back. The healing requires three conditions: (a) the revert must be **committed** (git blob hash must match HEAD again), (b) the memory must have been flagged by the system (not manually via `change_status`), and (c) you must run a lazy trigger (`retrieve`/`search`/`affected`) after the revert to scan for changes.
|
|
24
|
+
1. **Git-aware staleness (drift) detection.** Every memory can link to specific file paths, captured by git blob hash at record time. When the linked code changes, the memory is automatically flagged `needs_review` on the next `retrieve`/`search`/`affected` call — and a committed revert automatically heals it back. The healing requires three conditions: (a) the revert must be **committed** (git blob hash must match HEAD again), (b) the memory must have been flagged by the system (not manually via `change_status`), and (c) you must run a lazy trigger (`retrieve`/`search`/`affected`) after the revert to scan for changes. Few memory tools tie themselves to your actual code's history this deterministically — no embedding similarity, no LLM judgment call, just a git blob hash matching or not.
|
|
24
25
|
2. **Evidence, not vibes.** Memories can carry attached evidence (test output, a commit, a re-runnable command) with a mechanically computed strength — not a judgment call. A `provisional` memory only becomes `active` once real evidence backs it, or a human explicitly promotes it.
|
|
25
26
|
3. **Zero dependencies, fully local.** Pure stdlib + SQLite (FTS5 for search). No embeddings, no API keys, no network calls unless you explicitly configure Gitea evidence verification. `.cortex/memory.db` is just a file — inspect it with `sqlite3` any time.
|
|
26
27
|
4. **A real lifecycle with an audit trail.** Every status change (`active` → `superseded` → `archived`, etc.) requires a `--reason`, permanently recorded. Nothing disappears silently; wrong lessons are marked `invalidated`, not deleted.
|
|
@@ -94,6 +95,8 @@ roco record --type lesson --scope global \
|
|
|
94
95
|
--assumptions "css grid gap safari"
|
|
95
96
|
```
|
|
96
97
|
|
|
98
|
+
Global-scope commands (`record --scope global`, `show`, `search`, `status`, `link`, `evidence`, `list`) work from anywhere, including outside any git repository — the global store (`~/.cortex/global.db`) isn't tied to a project. `retrieve` is the one exception: it's local-repo-aware by design, so it still requires an initialized repo.
|
|
99
|
+
|
|
97
100
|
### Enable enforcement (recommended)
|
|
98
101
|
|
|
99
102
|
```bash
|
|
@@ -4,7 +4,7 @@ import sys
|
|
|
4
4
|
from contextlib import contextmanager
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
|
|
7
|
-
from robo_cortex.core.errors import RoboCortexError
|
|
7
|
+
from robo_cortex.core.errors import NotAGitRepoError, NotInitializedError, RoboCortexError
|
|
8
8
|
from robo_cortex.core.store import open_global_store, open_store
|
|
9
9
|
|
|
10
10
|
|
|
@@ -25,6 +25,26 @@ def _store(repo_arg):
|
|
|
25
25
|
conn.close()
|
|
26
26
|
|
|
27
27
|
|
|
28
|
+
@contextmanager
|
|
29
|
+
def _store_or_none(repo_arg):
|
|
30
|
+
"""Like `_store`, but yields (None, None) instead of raising when no
|
|
31
|
+
repo store is available (not inside a git repo, or `init` never ran
|
|
32
|
+
there) -- for commands that can still do useful work from the global
|
|
33
|
+
store alone (e.g. `show`/`search`/`status` on a scope='global' id) and
|
|
34
|
+
shouldn't hard-fail just because no *local* store happens to exist.
|
|
35
|
+
|
|
36
|
+
`find_memory_store`/`find_evidence_store` already accept `local_conn is
|
|
37
|
+
None` and raise a clear, actionable error in the one case that still
|
|
38
|
+
needs it: `--scope repo` explicitly requested with no repo store to
|
|
39
|
+
satisfy it.
|
|
40
|
+
"""
|
|
41
|
+
try:
|
|
42
|
+
with _store(repo_arg) as (repo_root, conn):
|
|
43
|
+
yield repo_root, conn
|
|
44
|
+
except (NotAGitRepoError, NotInitializedError):
|
|
45
|
+
yield None, None
|
|
46
|
+
|
|
47
|
+
|
|
28
48
|
@contextmanager
|
|
29
49
|
def _global_store():
|
|
30
50
|
conn = open_global_store()
|
|
@@ -3,15 +3,19 @@
|
|
|
3
3
|
import json
|
|
4
4
|
import sys
|
|
5
5
|
|
|
6
|
-
from robo_cortex.core.
|
|
7
|
-
|
|
6
|
+
from robo_cortex.core.evidence import (
|
|
7
|
+
EVIDENCE_KINDS,
|
|
8
|
+
attach_evidence,
|
|
9
|
+
find_evidence_store,
|
|
10
|
+
verify_evidence,
|
|
11
|
+
)
|
|
8
12
|
from robo_cortex.core.memory import find_memory_store
|
|
9
|
-
from robo_cortex.cli._common import _get_cmd_name,
|
|
13
|
+
from robo_cortex.cli._common import _get_cmd_name, _store_or_none, _global_store, cli_command
|
|
10
14
|
|
|
11
15
|
|
|
12
16
|
@cli_command("evidence add")
|
|
13
17
|
def run_add(args) -> int:
|
|
14
|
-
with
|
|
18
|
+
with _store_or_none(args.repo) as (repo_root, conn), _global_store() as global_conn:
|
|
15
19
|
store = find_memory_store(conn, global_conn, args.id, scope=args.scope)
|
|
16
20
|
result = attach_evidence(
|
|
17
21
|
store,
|
|
@@ -37,7 +41,7 @@ def run_add(args) -> int:
|
|
|
37
41
|
|
|
38
42
|
@cli_command("evidence verify")
|
|
39
43
|
def run_verify(args) -> int:
|
|
40
|
-
with
|
|
44
|
+
with _store_or_none(args.repo) as (repo_root, conn), _global_store() as global_conn:
|
|
41
45
|
# evidence rows live in whichever store their memory lives in;
|
|
42
46
|
# id sequences are independent per store. --scope disambiguates
|
|
43
47
|
# an id that collides between stores, same as for memory ids.
|
|
@@ -45,15 +49,8 @@ def run_verify(args) -> int:
|
|
|
45
49
|
# lives in: it's this invocation's ambient repo context, used to
|
|
46
50
|
# resolve the Gitea owner/repo via the local git remote
|
|
47
51
|
# (Stage 10) for gitea_pr/gitea_issue evidence specifically.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
elif args.scope == "global":
|
|
51
|
-
result = verify_evidence(global_conn, args.evidence_id, repo_root)
|
|
52
|
-
else:
|
|
53
|
-
try:
|
|
54
|
-
result = verify_evidence(conn, args.evidence_id, repo_root)
|
|
55
|
-
except NotFoundError:
|
|
56
|
-
result = verify_evidence(global_conn, args.evidence_id, repo_root)
|
|
52
|
+
store = find_evidence_store(conn, global_conn, args.evidence_id, scope=args.scope)
|
|
53
|
+
result = verify_evidence(store, args.evidence_id, repo_root)
|
|
57
54
|
|
|
58
55
|
print(json.dumps(result) if args.json else json.dumps(result, indent=2))
|
|
59
56
|
return 0
|
|
@@ -5,13 +5,13 @@ import sys
|
|
|
5
5
|
|
|
6
6
|
from robo_cortex.core.lifecycle import create_link
|
|
7
7
|
from robo_cortex.core.memory import find_memory_store
|
|
8
|
-
from robo_cortex.cli._common import _get_cmd_name,
|
|
8
|
+
from robo_cortex.cli._common import _get_cmd_name, _store_or_none, _global_store, LINK_TYPE_ARGS, cli_command
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
@cli_command("link")
|
|
12
12
|
def run(args) -> int:
|
|
13
13
|
link_type = LINK_TYPE_ARGS[args.link_type]
|
|
14
|
-
with
|
|
14
|
+
with _store_or_none(args.repo) as (_repo_root, conn), _global_store() as global_conn:
|
|
15
15
|
store1 = find_memory_store(conn, global_conn, args.id1, scope=args.scope)
|
|
16
16
|
store2 = find_memory_store(conn, global_conn, args.id2, scope=args.scope)
|
|
17
17
|
if store1 is not store2:
|
|
@@ -21,12 +21,16 @@ def run(args) -> int:
|
|
|
21
21
|
file=sys.stderr,
|
|
22
22
|
)
|
|
23
23
|
return 1
|
|
24
|
+
resolved_scope = "global" if store1 is global_conn else "repo"
|
|
24
25
|
result = create_link(store1, args.id1, args.id2, link_type)
|
|
25
26
|
|
|
26
27
|
if args.json:
|
|
27
|
-
print(json.dumps(result))
|
|
28
|
+
print(json.dumps({**result, "scope": resolved_scope}))
|
|
28
29
|
else:
|
|
29
|
-
print(
|
|
30
|
+
print(
|
|
31
|
+
f"Linked {result['from_id']} --{result['link_type']}--> "
|
|
32
|
+
f"{result['to_id']} ({resolved_scope})"
|
|
33
|
+
)
|
|
30
34
|
return 0
|
|
31
35
|
|
|
32
36
|
|
|
@@ -4,15 +4,23 @@ import json
|
|
|
4
4
|
import sys
|
|
5
5
|
|
|
6
6
|
from robo_cortex.core.memory import list_memories
|
|
7
|
-
from robo_cortex.cli._common import _get_cmd_name,
|
|
7
|
+
from robo_cortex.cli._common import _get_cmd_name, _store_or_none, _global_store, cli_command
|
|
8
8
|
from robo_cortex.cli._output import format_status
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
@cli_command("list")
|
|
12
12
|
def run(args) -> int:
|
|
13
|
-
with
|
|
13
|
+
with _store_or_none(args.repo) as (_repo_root, conn), _global_store() as global_conn:
|
|
14
|
+
if conn is None and args.scope == "repo":
|
|
15
|
+
print(
|
|
16
|
+
"robo-cortex list: no repo store available (not inside a git "
|
|
17
|
+
"repo, or 'robo-cortex init' never ran there) -- pass --repo, "
|
|
18
|
+
"or drop --scope repo to also list the global store",
|
|
19
|
+
file=sys.stderr,
|
|
20
|
+
)
|
|
21
|
+
return 2
|
|
14
22
|
results = []
|
|
15
|
-
if args.scope in (None, "repo"):
|
|
23
|
+
if conn is not None and args.scope in (None, "repo"):
|
|
16
24
|
results += list_memories(
|
|
17
25
|
conn,
|
|
18
26
|
status=args.status,
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"""Command: roco record"""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
from robo_cortex.core.memory import (
|
|
7
|
+
CONFIDENCES,
|
|
8
|
+
SCOPES,
|
|
9
|
+
STATEMENT_MAX,
|
|
10
|
+
TYPES,
|
|
11
|
+
WHY_IT_MATTERS_MAX,
|
|
12
|
+
ASSUMPTIONS_MAX,
|
|
13
|
+
record_batch,
|
|
14
|
+
record_memory,
|
|
15
|
+
)
|
|
16
|
+
from robo_cortex.core.invalidate import add_path, update_path
|
|
17
|
+
from robo_cortex.cli._common import _get_cmd_name, _store, _global_store, cli_command
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@cli_command("record")
|
|
21
|
+
def run(args) -> int:
|
|
22
|
+
# --update-path / --add-path / --batch are inherently repo-local
|
|
23
|
+
# operations (paths are repo-relative; --batch explicitly refuses
|
|
24
|
+
# scope='global' lines -- see record_batch), so these still need a
|
|
25
|
+
# real, initialized repo store unconditionally.
|
|
26
|
+
if args.update_path or args.add_path or args.batch:
|
|
27
|
+
with _store(args.repo) as (repo_root, conn):
|
|
28
|
+
if args.update_path:
|
|
29
|
+
if not (args.id and args.old_path and args.new_path):
|
|
30
|
+
print(
|
|
31
|
+
"robo-cortex record --update-path: ID, --old-path, "
|
|
32
|
+
"and --new-path are all required",
|
|
33
|
+
file=sys.stderr,
|
|
34
|
+
)
|
|
35
|
+
return 2
|
|
36
|
+
result = update_path(conn, repo_root, args.id, args.old_path, args.new_path)
|
|
37
|
+
if args.json:
|
|
38
|
+
print(json.dumps(result))
|
|
39
|
+
else:
|
|
40
|
+
print(f"Updated memory {result['id']}: {args.old_path} -> {args.new_path}")
|
|
41
|
+
return 0
|
|
42
|
+
|
|
43
|
+
if args.add_path:
|
|
44
|
+
if not args.id:
|
|
45
|
+
print(
|
|
46
|
+
"robo-cortex record --add-path: ID is required",
|
|
47
|
+
file=sys.stderr,
|
|
48
|
+
)
|
|
49
|
+
return 2
|
|
50
|
+
result = add_path(conn, repo_root, args.id, args.add_path)
|
|
51
|
+
if args.json:
|
|
52
|
+
print(json.dumps(result))
|
|
53
|
+
else:
|
|
54
|
+
print(f"Added path to memory {result['id']}: {args.add_path}")
|
|
55
|
+
return 0
|
|
56
|
+
|
|
57
|
+
lines = sys.stdin.read().splitlines()
|
|
58
|
+
result = record_batch(conn, repo_root, lines)
|
|
59
|
+
if args.json:
|
|
60
|
+
print(json.dumps(result))
|
|
61
|
+
else:
|
|
62
|
+
print(f"Created {result['created']} memories.")
|
|
63
|
+
for failure in result["failed"]:
|
|
64
|
+
print(
|
|
65
|
+
f" line {failure['line']}: {failure['error']}",
|
|
66
|
+
file=sys.stderr,
|
|
67
|
+
)
|
|
68
|
+
return 0
|
|
69
|
+
|
|
70
|
+
if not (args.type and args.scope and args.statement and args.confidence):
|
|
71
|
+
print(
|
|
72
|
+
"robo-cortex record: --type, --scope, --statement, and "
|
|
73
|
+
"--confidence are required (or use --batch to read JSON "
|
|
74
|
+
"Lines from stdin, --update-path to relink an existing "
|
|
75
|
+
"memory, or --add-path to attach a path to one)",
|
|
76
|
+
file=sys.stderr,
|
|
77
|
+
)
|
|
78
|
+
return 2
|
|
79
|
+
|
|
80
|
+
if args.scope == "global":
|
|
81
|
+
# scope='global' memories live in ~/.cortex/global.db, not the
|
|
82
|
+
# local repo store -- ARCHITECTURE.md §2: scope B "cannot live in
|
|
83
|
+
# one repository's .cortex/". Global records also cannot carry
|
|
84
|
+
# --path (validated in record_memory), so repo_root is never
|
|
85
|
+
# actually used for this branch -- no repo resolution needed at
|
|
86
|
+
# all, meaning `record --scope global` now works from anywhere,
|
|
87
|
+
# including outside any git repo.
|
|
88
|
+
with _global_store() as global_conn:
|
|
89
|
+
result = record_memory(
|
|
90
|
+
global_conn,
|
|
91
|
+
None,
|
|
92
|
+
type=args.type,
|
|
93
|
+
scope=args.scope,
|
|
94
|
+
statement=args.statement,
|
|
95
|
+
confidence=args.confidence,
|
|
96
|
+
why_it_matters=args.why_it_matters,
|
|
97
|
+
assumptions=args.assumptions,
|
|
98
|
+
paths=args.paths,
|
|
99
|
+
lesson_from=args.lesson_from,
|
|
100
|
+
)
|
|
101
|
+
else:
|
|
102
|
+
with _store(args.repo) as (repo_root, conn):
|
|
103
|
+
result = record_memory(
|
|
104
|
+
conn,
|
|
105
|
+
repo_root,
|
|
106
|
+
type=args.type,
|
|
107
|
+
scope=args.scope,
|
|
108
|
+
statement=args.statement,
|
|
109
|
+
confidence=args.confidence,
|
|
110
|
+
why_it_matters=args.why_it_matters,
|
|
111
|
+
assumptions=args.assumptions,
|
|
112
|
+
paths=args.paths,
|
|
113
|
+
lesson_from=args.lesson_from,
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
if args.json:
|
|
117
|
+
print(json.dumps(result))
|
|
118
|
+
else:
|
|
119
|
+
print(f"Recorded memory {result['id']} (status: {result['status']})")
|
|
120
|
+
for path in result["paths"]:
|
|
121
|
+
print(f" path: {path['path']} blob_hash: {path['blob_hash']}")
|
|
122
|
+
return 0
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def register(subparsers):
|
|
126
|
+
p = subparsers.add_parser(
|
|
127
|
+
"record",
|
|
128
|
+
help="Record a new memory",
|
|
129
|
+
description="Record a new memory in this repository or globally.\n"
|
|
130
|
+
"New memories start in 'provisional' status. Use 'roco status <id> activate' to promote to 'active', "
|
|
131
|
+
"or attach evidence which auto-promotes provisional→active on the first evidence.",
|
|
132
|
+
)
|
|
133
|
+
p.add_argument("id", nargs="?", type=int, default=None, help="Used with --update-path or --add-path")
|
|
134
|
+
p.add_argument("--repo", default=None)
|
|
135
|
+
p.add_argument("--type", choices=sorted(TYPES), default=None, help="Memory type: decision, lesson, fact, etc.")
|
|
136
|
+
p.add_argument("--scope", choices=sorted(SCOPES), default=None, help="Memory scope: 'repo' (this project) or 'global' (reusable)")
|
|
137
|
+
p.add_argument(
|
|
138
|
+
"--statement", default=None,
|
|
139
|
+
help=f"The memory itself, in plain language (max {STATEMENT_MAX} characters)",
|
|
140
|
+
)
|
|
141
|
+
p.add_argument(
|
|
142
|
+
"--confidence", choices=sorted(CONFIDENCES), default=None,
|
|
143
|
+
help="Confidence level: low, medium, or high"
|
|
144
|
+
)
|
|
145
|
+
p.add_argument(
|
|
146
|
+
"--why", dest="why_it_matters", default=None,
|
|
147
|
+
help=f"Why this matters (max {WHY_IT_MATTERS_MAX} characters)",
|
|
148
|
+
)
|
|
149
|
+
p.add_argument(
|
|
150
|
+
"--assumptions", default=None,
|
|
151
|
+
help=f"Comma-separated preconditions (max {ASSUMPTIONS_MAX} characters); "
|
|
152
|
+
"required for scope='global' -- all must match the task text "
|
|
153
|
+
"verbatim for the memory to be retrieved",
|
|
154
|
+
)
|
|
155
|
+
p.add_argument(
|
|
156
|
+
"--path", dest="paths", action="append", default=[]
|
|
157
|
+
)
|
|
158
|
+
p.add_argument(
|
|
159
|
+
"--lesson-from", dest="lesson_from", type=int, default=None,
|
|
160
|
+
help="Link a new type=lesson memory back to the abandoned memory it compresses",
|
|
161
|
+
)
|
|
162
|
+
p.add_argument(
|
|
163
|
+
"--batch",
|
|
164
|
+
action="store_true",
|
|
165
|
+
help="Read JSON Lines from stdin instead of the flags above",
|
|
166
|
+
)
|
|
167
|
+
p.add_argument(
|
|
168
|
+
"--update-path", action="store_true",
|
|
169
|
+
help="Relink an existing memory's path (needs ID, --old-path, --new-path)",
|
|
170
|
+
)
|
|
171
|
+
p.add_argument("--old-path", default=None)
|
|
172
|
+
p.add_argument("--new-path", default=None)
|
|
173
|
+
p.add_argument(
|
|
174
|
+
"--add-path", dest="add_path", default=None,
|
|
175
|
+
help="Attach a new path to an existing memory (needs ID and --add-path); "
|
|
176
|
+
"useful for a file that didn't exist at HEAD when the memory was first recorded",
|
|
177
|
+
)
|
|
178
|
+
p.add_argument("--json", action="store_true")
|
|
179
|
+
p.set_defaults(func=run)
|
|
@@ -14,6 +14,12 @@ from robo_cortex.cli._output import _format_score_breakdown, format_status
|
|
|
14
14
|
|
|
15
15
|
@cli_command("retrieve")
|
|
16
16
|
def run(args) -> int:
|
|
17
|
+
# Deliberately strict, unlike show/search/status/... below: retrieve's
|
|
18
|
+
# whole purpose is local-repo-aware context, so an uninitialized repo
|
|
19
|
+
# (forgot to run `init`) should fail loudly, not silently degrade to
|
|
20
|
+
# global-only results that could read as "nothing relevant here" when
|
|
21
|
+
# the real problem is the missing local store. Pinned by
|
|
22
|
+
# tests/test_sdk.py::test_retrieve_on_uninitialized_repo_raises_not_initialized.
|
|
17
23
|
if not args.task:
|
|
18
24
|
print("robo-cortex retrieve: --task is required", file=sys.stderr)
|
|
19
25
|
return 2
|
|
@@ -4,7 +4,7 @@ import json
|
|
|
4
4
|
import sys
|
|
5
5
|
|
|
6
6
|
from robo_cortex.core.retrieve import DEFAULT_SEARCH_LIMIT, search_memory
|
|
7
|
-
from robo_cortex.cli._common import _get_cmd_name,
|
|
7
|
+
from robo_cortex.cli._common import _get_cmd_name, _store_or_none, _global_store, cli_command
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
@cli_command("search")
|
|
@@ -13,7 +13,15 @@ def run(args) -> int:
|
|
|
13
13
|
print("robo-cortex search: --query is required", file=sys.stderr)
|
|
14
14
|
return 2
|
|
15
15
|
|
|
16
|
-
with
|
|
16
|
+
with _store_or_none(args.repo) as (repo_root, conn), _global_store() as global_conn:
|
|
17
|
+
if conn is None and args.scope == "repo":
|
|
18
|
+
print(
|
|
19
|
+
"robo-cortex search: no repo store available (not inside a git "
|
|
20
|
+
"repo, or 'robo-cortex init' never ran there) -- pass --repo, "
|
|
21
|
+
"or drop --scope repo to also search the global store",
|
|
22
|
+
file=sys.stderr,
|
|
23
|
+
)
|
|
24
|
+
return 2
|
|
17
25
|
result = search_memory(
|
|
18
26
|
conn,
|
|
19
27
|
repo_root,
|
|
@@ -5,13 +5,13 @@ import sys
|
|
|
5
5
|
|
|
6
6
|
from robo_cortex.core.memory import find_memory_store, get_memory
|
|
7
7
|
from robo_cortex.core.retrieve import explain_memory_score
|
|
8
|
-
from robo_cortex.cli._common import _get_cmd_name,
|
|
8
|
+
from robo_cortex.cli._common import _get_cmd_name, _store_or_none, _global_store, cli_command
|
|
9
9
|
from robo_cortex.cli._output import _format_score_breakdown, format_status
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
@cli_command("show")
|
|
13
13
|
def run(args) -> int:
|
|
14
|
-
with
|
|
14
|
+
with _store_or_none(args.repo) as (_repo_root, conn), _global_store() as global_conn:
|
|
15
15
|
store = find_memory_store(conn, global_conn, args.id, scope=args.scope)
|
|
16
16
|
result = get_memory(store, args.id)
|
|
17
17
|
if args.explain_against:
|
|
@@ -5,12 +5,12 @@ import sys
|
|
|
5
5
|
|
|
6
6
|
from robo_cortex.core.lifecycle import STATUS_ACTIONS, change_status, status_batch
|
|
7
7
|
from robo_cortex.core.memory import find_memory_store
|
|
8
|
-
from robo_cortex.cli._common import _get_cmd_name,
|
|
8
|
+
from robo_cortex.cli._common import _get_cmd_name, _store_or_none, _global_store, cli_command
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
@cli_command("status")
|
|
12
12
|
def run(args) -> int:
|
|
13
|
-
with
|
|
13
|
+
with _store_or_none(args.repo) as (repo_root, conn), _global_store() as global_conn:
|
|
14
14
|
if args.batch:
|
|
15
15
|
lines = sys.stdin.read().splitlines()
|
|
16
16
|
result = status_batch(conn, global_conn, repo_root, lines)
|
|
@@ -39,15 +39,16 @@ def run(args) -> int:
|
|
|
39
39
|
|
|
40
40
|
new_status = STATUS_ACTIONS[args.action]
|
|
41
41
|
store = find_memory_store(conn, global_conn, args.id, scope=args.scope)
|
|
42
|
+
resolved_scope = "global" if store is global_conn else "repo"
|
|
42
43
|
result = change_status(
|
|
43
44
|
store, repo_root, args.id, new_status, args.reason,
|
|
44
45
|
supersedes_link_to=args.supersedes,
|
|
45
46
|
)
|
|
46
47
|
|
|
47
48
|
if args.json:
|
|
48
|
-
print(json.dumps(result))
|
|
49
|
+
print(json.dumps({**result, "scope": resolved_scope}))
|
|
49
50
|
else:
|
|
50
|
-
print(f"Memory {result['id']} -> {result['status']}")
|
|
51
|
+
print(f"Memory {result['id']} ({resolved_scope}) -> {result['status']}")
|
|
51
52
|
return 0
|
|
52
53
|
|
|
53
54
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from datetime import datetime, timezone
|
|
2
2
|
|
|
3
|
-
from .errors import NotFoundError, ValidationError
|
|
3
|
+
from .errors import AmbiguousIdError, NotFoundError, ValidationError
|
|
4
4
|
from .memory import get_memory, reverify
|
|
5
5
|
|
|
6
6
|
EVIDENCE_KINDS = {
|
|
@@ -107,6 +107,55 @@ def _mark_unverifiable(conn, evidence_id: int, kind: str, ref: str | None, reaso
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
|
|
110
|
+
def find_evidence_store(local_conn, global_conn, evidence_id: int, scope: str | None = None):
|
|
111
|
+
"""Same shape as `memory.find_memory_store`, for evidence rows: evidence
|
|
112
|
+
ids are also a per-store autoincrement sequence, so a bare id can
|
|
113
|
+
collide between the repo and global stores just like memory ids do.
|
|
114
|
+
`scope=None` checks both and raises AmbiguousIdError on a double hit
|
|
115
|
+
instead of silently verifying whichever store's row happened to match
|
|
116
|
+
first -- the same failure mode reported for memory ids in
|
|
117
|
+
prompt-bug-roco.md, just not routed through find_memory_store because
|
|
118
|
+
evidence rows aren't looked up by `get_memory`.
|
|
119
|
+
|
|
120
|
+
`local_conn` may be `None` -- same as `find_memory_store`, this is fine
|
|
121
|
+
for a scope='global' lookup but not for an explicit `scope='repo'` one.
|
|
122
|
+
"""
|
|
123
|
+
def _has_evidence(conn) -> bool:
|
|
124
|
+
return conn is not None and conn.execute(
|
|
125
|
+
"SELECT 1 FROM evidence WHERE id = ?", (evidence_id,)
|
|
126
|
+
).fetchone() is not None
|
|
127
|
+
|
|
128
|
+
if scope == "repo":
|
|
129
|
+
if local_conn is None:
|
|
130
|
+
raise NotFoundError(
|
|
131
|
+
f"no evidence with id {evidence_id}: no repo store available "
|
|
132
|
+
"(not inside a git repo, or 'robo-cortex init' never ran "
|
|
133
|
+
"there) -- pass --repo, or drop --scope repo to also check "
|
|
134
|
+
"the global store"
|
|
135
|
+
)
|
|
136
|
+
if not _has_evidence(local_conn):
|
|
137
|
+
raise NotFoundError(f"no evidence with id {evidence_id}")
|
|
138
|
+
return local_conn
|
|
139
|
+
if scope == "global":
|
|
140
|
+
if global_conn is None or not _has_evidence(global_conn):
|
|
141
|
+
raise NotFoundError(f"no evidence with id {evidence_id}")
|
|
142
|
+
return global_conn
|
|
143
|
+
|
|
144
|
+
local_hit = _has_evidence(local_conn)
|
|
145
|
+
global_hit = global_conn is not None and _has_evidence(global_conn)
|
|
146
|
+
|
|
147
|
+
if local_hit and global_hit:
|
|
148
|
+
raise AmbiguousIdError(
|
|
149
|
+
f"evidence id {evidence_id} exists in both repo and global stores -- "
|
|
150
|
+
"pass --scope repo or --scope global to disambiguate"
|
|
151
|
+
)
|
|
152
|
+
if local_hit:
|
|
153
|
+
return local_conn
|
|
154
|
+
if global_hit:
|
|
155
|
+
return global_conn
|
|
156
|
+
raise NotFoundError(f"no evidence with id {evidence_id}")
|
|
157
|
+
|
|
158
|
+
|
|
110
159
|
def verify_evidence(conn, evidence_id: int, repo_root=None) -> dict:
|
|
111
160
|
"""The single explicit re-verification entry point (ARCHITECTURE.md §3,
|
|
112
161
|
§9) -- the only place a network call to Gitea is ever allowed, and only
|