Require a token for writes and quarantine what nobody vouches for
Sixteen mutating routes now refuse a caller who cannot present the token the server started with; queries stay open, because a question is not a write. The environment variable is ELY_EYE_AUTH_TOKEN, following the repo's env_prefix convention — the shorter name I reached for first returned 403 where the smoke expected 401, and the server printed the reason. Words from a stranger are quarantined on the way in: an HTTP upload is third_party by definition, and a sentence carrying an instruction-shaped phrase is quarantined whoever wrote it. A quarantined atom stays findable and stays out of the compiled context until a second, live, unquarantined source agrees with its rarest words. Corroboration is computed at read time because it is a property of the corpus now, not of the moment a memory was written; it is term-level, and the docstring says so. forget now erases the source row and the compiled contexts beside the atoms, so a forgotten memory leaves nothing that can still speak. The semantic cache key carries a store revision, which fixes a real staleness: a context compiled before new evidence arrived kept its old quarantine decision forever. bench.audit --product still pointed at evals.py, which the p1-6 split moved into backend/src/ely_eye/proofs/. It failed fast, but the anti-self-justification rule had quietly stopped auditing the product; it now walks the package, and a test pins that the package exists and holds no re-roll. Gates: pytest 306 passed; ruff clean; mypy cold cache 24 errors in 9 files, the recorded baseline, net zero; pyright 0 errors on the 23 backend files and the 2 bench files; go build/vet/test and gofmt clean; npm run build 221.39 kB with eslint exit 0; bench/filesize_check clean; bench.audit --product clean over 31 harness files; scripts/mcp_write_smoke.sh PASS with the gate live across two servers and the MCP child.
This commit is contained in:
1 parent
8b974e6626
commit
9145a23f18
32 files changed
+750
-58
No files matched your search
@@ -9,6 +9,8 @@ from typing import Any
|
||||
|
||||
import pytest
|
||||
|
||||
from ely_eye.cache_fabric import CacheFabric
|
||||
from ely_eye.cartridge_store import add_membership
|
||||
from ely_eye.config import Settings
|
||||
from ely_eye.db import Database
|
||||
from ely_eye.memory import MemoryService
|
||||
@@ -136,14 +138,21 @@ def test_forget_reaches_every_copy_of_a_memory(
|
||||
[{"from_atom_id": "seed-1:text", "to_atom_id": "other", "relation": "cites", "confidence": 1.0}]
|
||||
)
|
||||
service.db.log_cache_event(layer="compiler", cache_key="k", event="hit", bytes_estimate=10)
|
||||
CacheFabric(service.settings, service.db).write_semantic_cache("compiled-1", {"packed_text": KEYS})
|
||||
VectorIndex(service.settings, service.db, fake_embeddings()).sync()
|
||||
|
||||
report = service.forget(atom_id="seed-1:text", reason="the drawer is empty")
|
||||
|
||||
assert report.atoms_deleted == 1
|
||||
assert report.edges_deleted == 1
|
||||
assert report.cache_entries_cleared == 1
|
||||
assert report.cache_entries_cleared == 2
|
||||
assert report.vectors_dropped == 1
|
||||
assert report.semantic_cache_cleared == 1
|
||||
assert not (service.settings.cache_dir / "semantic" / "compiled-1.json").exists()
|
||||
with service.db.connect() as connection:
|
||||
assert connection.execute("SELECT COUNT(*) FROM sources").fetchone()[0] == 0, (
|
||||
"a forgotten memory leaves no record of where it came from"
|
||||
)
|
||||
assert VectorIndex(service.settings, service.db, fake_embeddings()).stats()["vectors"] == 0
|
||||
assert service.db.atom_count() == 0
|
||||
with service.db.connect() as connection:
|
||||
@@ -170,8 +179,13 @@ def test_forget_names_the_cartridge_that_exported_the_source(service: MemoryServ
|
||||
token_equivalent=6,
|
||||
created_at=NOW,
|
||||
)
|
||||
add_membership(service.db, "cart-1", ["seed-1:text"])
|
||||
report = service.forget(source_id="seed-1")
|
||||
assert report.affected_cartridges == [{"cartridge_id": "cart-1", "contains_source": True}]
|
||||
with service.db.connect() as connection:
|
||||
assert connection.execute("SELECT COUNT(*) FROM cartridge_atoms").fetchone()[0] == 0, (
|
||||
"a cartridge must stop holding a memory that no longer exists"
|
||||
)
|
||||
|
||||
|
||||
def test_forget_refuses_a_request_that_names_nothing(service: MemoryService) -> None:
|
||||
|
||||
Reference in new issue
Block a user