coldmemory 0.3.6__py3-none-any.whl
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.
- coldmemory/__init__.py +15 -0
- coldmemory/__main__.py +135 -0
- coldmemory/adversarial_ingest_bench.py +137 -0
- coldmemory/bench_v1.py +792 -0
- coldmemory/benchmark.py +292 -0
- coldmemory/cartridge_spec.py +559 -0
- coldmemory/citations.py +27 -0
- coldmemory/disk_index.py +3553 -0
- coldmemory/hermes_provider.py +135 -0
- coldmemory/hooks_snippet.py +161 -0
- coldmemory/hybrid.py +430 -0
- coldmemory/ingest.py +742 -0
- coldmemory/ingest_policy.py +46 -0
- coldmemory/init_cmd.py +2279 -0
- coldmemory/ledger.py +417 -0
- coldmemory/mcp_server.py +677 -0
- coldmemory/multihop_retriever.py +429 -0
- coldmemory/push.py +351 -0
- coldmemory/redact.py +133 -0
- coldmemory/scope_keys.py +95 -0
- coldmemory/sessions.py +236 -0
- coldmemory/verifier.py +1696 -0
- coldmemory-0.3.6.data/data/share/coldmemory/integrations/hermes/coldmemory/__init__.py +10 -0
- coldmemory-0.3.6.data/data/share/coldmemory/integrations/hermes/coldmemory/plugin.yaml +3 -0
- coldmemory-0.3.6.data/data/share/coldmemory/skills/coldmemory/SKILL.md +53 -0
- coldmemory-0.3.6.dist-info/METADATA +320 -0
- coldmemory-0.3.6.dist-info/RECORD +31 -0
- coldmemory-0.3.6.dist-info/WHEEL +5 -0
- coldmemory-0.3.6.dist-info/entry_points.txt +5 -0
- coldmemory-0.3.6.dist-info/licenses/LICENSE +202 -0
- coldmemory-0.3.6.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""Owner-defined release gates for a non-private corpus."""
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
|
|
5
|
+
from .ingest import frontmatter
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ReleaseDenied(ValueError):
|
|
9
|
+
pass
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def check_release(corpus, approved, scope, policy):
|
|
13
|
+
if not isinstance(policy, dict) or policy.keys() != {"mosaics"} or not isinstance(policy["mosaics"], list):
|
|
14
|
+
raise ValueError("release policy must contain a mosaics array")
|
|
15
|
+
records = []
|
|
16
|
+
for note in corpus.notes.values():
|
|
17
|
+
meta, start = frontmatter(note.lines)
|
|
18
|
+
if note.lines[0].strip() == "---" and start == 0:
|
|
19
|
+
raise ReleaseDenied("unterminated document frontmatter")
|
|
20
|
+
labels = meta.get("classification", [scope]).copy()
|
|
21
|
+
if not labels:
|
|
22
|
+
raise ReleaseDenied("missing document classification value")
|
|
23
|
+
for line in note.lines[start:]:
|
|
24
|
+
match = re.fullmatch(r"\s*\*{0,2}classification\*{0,2}:\*{0,2}\s*(.*?)\s*", line, re.I)
|
|
25
|
+
if match:
|
|
26
|
+
labels.append(match[1].strip("\"'"))
|
|
27
|
+
if (any(label.casefold() != scope for label in labels)
|
|
28
|
+
or {"private", "restricted"}.intersection(note.tags)):
|
|
29
|
+
raise ReleaseDenied("document classification prevents release")
|
|
30
|
+
records.append("\n".join([note.key, *note.lines]).casefold())
|
|
31
|
+
for entry in approved:
|
|
32
|
+
text = entry["title"] + "\n" + entry["decision"]
|
|
33
|
+
if re.search(r"(?<!\w)#(?:private|restricted)\b", text, re.I):
|
|
34
|
+
raise ReleaseDenied("document classification prevents release")
|
|
35
|
+
records.append(text.casefold())
|
|
36
|
+
for rule in policy["mosaics"]:
|
|
37
|
+
if not isinstance(rule, dict) or rule.keys() != {"entity", "facts"}:
|
|
38
|
+
raise ValueError("invalid mosaic rule")
|
|
39
|
+
entity, facts = rule["entity"], rule["facts"]
|
|
40
|
+
if (not isinstance(entity, str) or not entity.strip() or not isinstance(facts, list)
|
|
41
|
+
or any(not isinstance(f, str) or not f.strip() for f in facts)
|
|
42
|
+
or len({f.strip().casefold() for f in facts}) < 2):
|
|
43
|
+
raise ValueError("a mosaic rule needs an entity and two distinct facts")
|
|
44
|
+
linked = [record for record in records if entity.strip().casefold() in record]
|
|
45
|
+
if all(any(fact.strip().casefold() in record for record in linked) for fact in facts):
|
|
46
|
+
raise ReleaseDenied("entity and restricted combination of facts occur in this release")
|