verilore 0.11.0__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.
- verilore/__init__.py +93 -0
- verilore/api/__init__.py +0 -0
- verilore/api/dependencies.py +33 -0
- verilore/api/errors.py +52 -0
- verilore/api/main.py +627 -0
- verilore/api/models/memory.py +320 -0
- verilore/api/models/remember.py +173 -0
- verilore/api/models/schemas.py +491 -0
- verilore/api/routers/__init__.py +0 -0
- verilore/api/routers/context.py +129 -0
- verilore/api/routers/corpora.py +156 -0
- verilore/api/routers/ingest.py +85 -0
- verilore/api/routers/memory.py +352 -0
- verilore/api/routers/query.py +449 -0
- verilore/api/routers/search.py +102 -0
- verilore/api/runtime.py +801 -0
- verilore/api/services/__init__.py +24 -0
- verilore/api/services/authz.py +707 -0
- verilore/api/services/benchmark.py +304 -0
- verilore/api/services/chunker.py +69 -0
- verilore/api/services/claim_embeddings.py +315 -0
- verilore/api/services/confidence.py +143 -0
- verilore/api/services/context_packer.py +640 -0
- verilore/api/services/context_service.py +184 -0
- verilore/api/services/corpora.py +347 -0
- verilore/api/services/db.py +258 -0
- verilore/api/services/embedder.py +512 -0
- verilore/api/services/evaluation.py +122 -0
- verilore/api/services/ingest_paths.py +114 -0
- verilore/api/services/ingestion.py +1158 -0
- verilore/api/services/llm.py +161 -0
- verilore/api/services/llm_service.py +30 -0
- verilore/api/services/markdown_claims.py +1264 -0
- verilore/api/services/memory.py +1726 -0
- verilore/api/services/memory_adjudication.py +214 -0
- verilore/api/services/memory_benchmark.py +1531 -0
- verilore/api/services/memory_decision_benchmark.py +131 -0
- verilore/api/services/memory_decision_dataset.py +152 -0
- verilore/api/services/memory_decision_spike.py +276 -0
- verilore/api/services/memory_evaluation_lab.py +172 -0
- verilore/api/services/memory_feed.py +212 -0
- verilore/api/services/memory_public.py +752 -0
- verilore/api/services/memory_query.py +791 -0
- verilore/api/services/memory_query_benchmark.py +1275 -0
- verilore/api/services/memory_reasoning.py +338 -0
- verilore/api/services/memory_relevance.py +893 -0
- verilore/api/services/observability.py +72 -0
- verilore/api/services/parser.py +624 -0
- verilore/api/services/posture.py +384 -0
- verilore/api/services/quality_gate.py +136 -0
- verilore/api/services/query_log.py +281 -0
- verilore/api/services/rehydrate.py +237 -0
- verilore/api/services/related.py +22 -0
- verilore/api/services/remember.py +714 -0
- verilore/api/services/repository.py +496 -0
- verilore/api/services/reranker.py +69 -0
- verilore/api/services/resources.py +128 -0
- verilore/api/services/retrieval.py +394 -0
- verilore/api/services/retrieval_mode.py +49 -0
- verilore/api/services/revalidate.py +612 -0
- verilore/api/services/similarity.py +121 -0
- verilore/api/services/source_formats.py +349 -0
- verilore/api/services/telemetry.py +132 -0
- verilore/api/services/timeline.py +36 -0
- verilore/cli/__init__.py +0 -0
- verilore/cli/config.py +149 -0
- verilore/cli/doctor.py +423 -0
- verilore/cli/errors.py +408 -0
- verilore/cli/main.py +2882 -0
- verilore/cli/memory.py +287 -0
- verilore/cli/postgres.py +922 -0
- verilore/cli/render.py +446 -0
- verilore/cli/runtime.py +136 -0
- verilore/errors.py +544 -0
- verilore/mcp_server.py +695 -0
- verilore/migrations/__init__.py +36 -0
- verilore/migrations/alembic.ini +41 -0
- verilore/migrations/env.py +70 -0
- verilore/migrations/versions/001_initial_schema.py +167 -0
- verilore/migrations/versions/002_corpora.py +72 -0
- verilore/migrations/versions/003_manifest_corpus.py +39 -0
- verilore/migrations/versions/004_memory.py +288 -0
- verilore/migrations/versions/005_multiple_evidence.py +60 -0
- verilore/migrations/versions/006_snapshot_membership_seal.py +94 -0
- verilore/migrations/versions/007_claim_embedding_cache.py +66 -0
- verilore/migrations/versions/008_tenant_scoped_access.py +156 -0
- verilore/migrations/versions/009_permission_granularity_and_erasure.py +285 -0
- verilore/migrations/versions/010_bind_unrestricted_scope.py +244 -0
- verilore/migrations/versions/011_cross_document_supersession.py +148 -0
- verilore/migrations/versions/012_claim_embedding_hnsw.py +71 -0
- verilore/migrations/versions/013_info_state_and_extraction_mode.py +27 -0
- verilore/migrations/versions/014_scope_token_hardening.py +160 -0
- verilore/migrations/versions/015_rls_scope_enforcement.py +200 -0
- verilore/migrations/versions/016_hoist_scope_initplan.py +95 -0
- verilore/pack.py +470 -0
- verilore/proof.py +493 -0
- verilore/proof_cli.py +551 -0
- verilore/receipt.py +567 -0
- verilore/runtime.py +44 -0
- verilore/sdk.py +1588 -0
- verilore-0.11.0.dist-info/METADATA +118 -0
- verilore-0.11.0.dist-info/RECORD +109 -0
- verilore-0.11.0.dist-info/WHEEL +5 -0
- verilore-0.11.0.dist-info/entry_points.txt +4 -0
- verilore-0.11.0.dist-info/licenses/LICENSE +51 -0
- verilore-0.11.0.dist-info/licenses/NOTICE +4 -0
- verilore-0.11.0.dist-info/top_level.txt +3 -0
- verilore_errors.py +14 -0
- verilore_sdk.py +14 -0
verilore/__init__.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Copyright 2026 Raunak Dey
|
|
3
|
+
|
|
4
|
+
"""Top-level ``verilore`` package.
|
|
5
|
+
|
|
6
|
+
The wheel ships exactly one importable namespace, ``verilore`` (plus the two
|
|
7
|
+
one-release shims ``verilore_sdk`` and ``verilore_errors``). The public surface
|
|
8
|
+
lives in the submodules -- ``verilore.sdk``, ``verilore.errors``, ``verilore.api``,
|
|
9
|
+
``verilore.cli``, ``verilore.mcp_server``, ``verilore.pack``, ``verilore.proof``,
|
|
10
|
+
``verilore.proof_cli``, ``verilore.receipt``, ``verilore.runtime`` -- and the
|
|
11
|
+
names below are re-exported lazily so that ``import verilore`` itself pulls in
|
|
12
|
+
none of httpx, fastapi, sqlalchemy, onnxruntime, or the api/cli surfaces.
|
|
13
|
+
|
|
14
|
+
from verilore import Verilore
|
|
15
|
+
|
|
16
|
+
is the documented import. The top-level ``verilore_sdk`` and ``verilore_errors``
|
|
17
|
+
modules remain as deprecated shims for v0.11.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
import importlib.metadata
|
|
23
|
+
import sys
|
|
24
|
+
|
|
25
|
+
try: # The distribution is installed (editable or wheel) in every real environment.
|
|
26
|
+
__version__ = importlib.metadata.version("verilore")
|
|
27
|
+
except importlib.metadata.PackageNotFoundError: # pragma: no cover - source tree without install
|
|
28
|
+
__version__ = "0.11.0"
|
|
29
|
+
|
|
30
|
+
#: Lazy public names -> the submodule that defines them. Imported on first access.
|
|
31
|
+
_LAZY = {
|
|
32
|
+
# From verilore.sdk.
|
|
33
|
+
"DEFAULT_CORPUS": "verilore.sdk",
|
|
34
|
+
"CorpusNotFoundError": "verilore.sdk",
|
|
35
|
+
"DatabaseUnavailableError": "verilore.sdk",
|
|
36
|
+
"MemoryClient": "verilore.sdk",
|
|
37
|
+
"MemoryClientError": "verilore.sdk",
|
|
38
|
+
"MemoryResult": "verilore.sdk",
|
|
39
|
+
"Verilore": "verilore.sdk",
|
|
40
|
+
"VeriloreAuthenticationError": "verilore.sdk",
|
|
41
|
+
"VeriloreConflictError": "verilore.sdk",
|
|
42
|
+
"VeriloreError": "verilore.sdk",
|
|
43
|
+
"VeriloreInternalError": "verilore.sdk",
|
|
44
|
+
"VeriloreNotFoundError": "verilore.sdk",
|
|
45
|
+
"VeriloreTransportError": "verilore.sdk",
|
|
46
|
+
"VeriloreUnauthorizedError": "verilore.sdk",
|
|
47
|
+
"VeriloreValidationError": "verilore.sdk",
|
|
48
|
+
"ProviderAuthenticationError": "verilore.sdk",
|
|
49
|
+
"ProviderError": "verilore.sdk",
|
|
50
|
+
"ProviderIncompatibleModelError": "verilore.sdk",
|
|
51
|
+
"ProviderMalformedResponseError": "verilore.sdk",
|
|
52
|
+
"ProviderRateLimitError": "verilore.sdk",
|
|
53
|
+
"ProviderRefusedError": "verilore.sdk",
|
|
54
|
+
"ProviderTimeoutError": "verilore.sdk",
|
|
55
|
+
"ProviderUnavailableError": "verilore.sdk",
|
|
56
|
+
"ReceiptError": "verilore.sdk",
|
|
57
|
+
"SyncSummary": "verilore.sdk",
|
|
58
|
+
"verify_receipt": "verilore.sdk",
|
|
59
|
+
"verify_response_receipt": "verilore.sdk",
|
|
60
|
+
"verify_trust": "verilore.sdk",
|
|
61
|
+
# From verilore.errors.
|
|
62
|
+
"COMPONENTS": "verilore.errors",
|
|
63
|
+
"AuthenticationError": "verilore.errors",
|
|
64
|
+
"ConflictError": "verilore.errors",
|
|
65
|
+
"DatabaseSchemaError": "verilore.errors",
|
|
66
|
+
"InternalError": "verilore.errors",
|
|
67
|
+
"NotFoundError": "verilore.errors",
|
|
68
|
+
"RequestId": "verilore.errors",
|
|
69
|
+
"TransportError": "verilore.errors",
|
|
70
|
+
"UnauthorizedError": "verilore.errors",
|
|
71
|
+
"ValidationError": "verilore.errors",
|
|
72
|
+
"classify_provider_error": "verilore.errors",
|
|
73
|
+
"envelope": "verilore.errors",
|
|
74
|
+
"new_request_id": "verilore.errors",
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def __getattr__(name: str):
|
|
79
|
+
"""Lazy attribute access: import a submodule only when one of its names is used."""
|
|
80
|
+
submodule = _LAZY.get(name)
|
|
81
|
+
if submodule is None:
|
|
82
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
83
|
+
module = sys.modules.get(submodule)
|
|
84
|
+
if module is None:
|
|
85
|
+
module = __import__(submodule, fromlist=[name])
|
|
86
|
+
value = getattr(module, name)
|
|
87
|
+
# Cache on the package so subsequent lookups skip the import.
|
|
88
|
+
setattr(sys.modules[__name__], name, value)
|
|
89
|
+
return value
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def __dir__() -> list[str]:
|
|
93
|
+
return sorted(list(globals()) + list(_LAZY))
|
verilore/api/__init__.py
ADDED
|
File without changes
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Copyright 2026 Raunak Dey
|
|
3
|
+
|
|
4
|
+
"""Request-scoped authentication for the HTTP surface.
|
|
5
|
+
|
|
6
|
+
Authentication is a middleware, not a per-route dependency, and that is a
|
|
7
|
+
deliberate choice. A dependency runs only for routes that declare it, so the
|
|
8
|
+
next route added without it would be an unauthenticated route -- and nothing
|
|
9
|
+
would say so until it leaked. A middleware runs for every request the process
|
|
10
|
+
serves, so forgetting to protect a new endpoint is not possible.
|
|
11
|
+
|
|
12
|
+
The middleware also owns the teardown. A principal left in a `ContextVar` would
|
|
13
|
+
be inherited by the next request served on the same task, so request N+1 would
|
|
14
|
+
be scoped to request N's credential. Exiting the scope in a `finally` is what
|
|
15
|
+
makes "one request, one identity" true rather than merely intended;
|
|
16
|
+
`tests/test_tenant_isolation.py` asserts it by interleaving two identities
|
|
17
|
+
through one client.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
from verilore.api.services.authz import Principal
|
|
23
|
+
from verilore.api.services.db import current_principal
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def request_principal(request) -> Principal:
|
|
27
|
+
"""The identity resolved for this request.
|
|
28
|
+
|
|
29
|
+
Reads the `ContextVar` rather than request state so that a route handler, a
|
|
30
|
+
service several layers down, and a background task started from the handler
|
|
31
|
+
all see the same identity, and all of them see the same one.
|
|
32
|
+
"""
|
|
33
|
+
return current_principal()
|
verilore/api/errors.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Copyright 2026 Raunak Dey
|
|
3
|
+
|
|
4
|
+
"""The one place that explains a dead database.
|
|
5
|
+
|
|
6
|
+
Both `verilore init` and the per-command failure text need to say the same
|
|
7
|
+
thing, so the guidance lives here and is imported rather than restated. The
|
|
8
|
+
underlying exception is never the only thing a developer sees, and never the
|
|
9
|
+
first: it is appended for debugging, after the reason and the command to run.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def database_hint() -> str:
|
|
16
|
+
"""Where Verilore believes the database is, named for this process.
|
|
17
|
+
|
|
18
|
+
Read from the environment rather than hardcoded, so the advice names the
|
|
19
|
+
database this command would actually use. Never raises: advice that fails is
|
|
20
|
+
worse than no advice.
|
|
21
|
+
"""
|
|
22
|
+
url = _url()
|
|
23
|
+
try:
|
|
24
|
+
from sqlalchemy.engine import make_url
|
|
25
|
+
|
|
26
|
+
parsed = make_url(url)
|
|
27
|
+
return f"{parsed.host or 'localhost'}:{parsed.port or 5432}"
|
|
28
|
+
except Exception: # noqa: BLE001 - a malformed URL must not break the message
|
|
29
|
+
return url
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _url() -> str:
|
|
33
|
+
import os
|
|
34
|
+
|
|
35
|
+
return os.getenv("DATABASE_URL", "postgresql://mpadmin:secret@localhost:5432/verilore")
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def storage_unavailable(exc: Exception | None = None) -> str:
|
|
39
|
+
"""The full explanation of a database that cannot be reached.
|
|
40
|
+
|
|
41
|
+
WHAT happened, WHY, and the exact commands to run.
|
|
42
|
+
"""
|
|
43
|
+
detail = f"\n\n{type(exc).__name__}: {exc}" if exc is not None else ""
|
|
44
|
+
return (
|
|
45
|
+
"Verilore needs persistent storage, and it could not reach it.\n"
|
|
46
|
+
"\n"
|
|
47
|
+
f"Why: it could not connect to PostgreSQL at {database_hint()}.\n"
|
|
48
|
+
"\n"
|
|
49
|
+
"What to do:\n"
|
|
50
|
+
" verilore init starts the local database, or says why it cannot\n"
|
|
51
|
+
" verilore doctor finds the cause if that does not fix it" + detail
|
|
52
|
+
)
|