mirror of
https://github.com/vectorize-io/hindsight.git
synced 2026-09-14 19:31:49 +08:00
21928d7c95
protobuf 7 was blocked only by opentelemetry-proto <1.44 capping protobuf<7.0; 1.44.0 raised the ceiling to <8.0. Bump the six coupled otel pins together (api/sdk/otlp-proto-http 1.41->1.44, the three 0.6x companions 0.62b1->0.65b0) and protobuf 6.33.5->7.35.1. Verified in a real env: the OTLP HTTP exporter's protobuf-serialized trace payload round-trips through otel's generated proto types, and the Prometheus metrics path works. The otel_component_type kwarg (reason for the original >=1.41 floor) is still present in 1.44.
261 lines
10 KiB
TOML
261 lines
10 KiB
TOML
[build-system]
|
|
requires = ["hatchling"]
|
|
build-backend = "hatchling.build"
|
|
|
|
[project]
|
|
name = "hindsight-api-slim"
|
|
version = "0.8.5"
|
|
description = "Hindsight: Agent Memory That Works Like Human Memory"
|
|
readme = "README.md"
|
|
requires-python = ">=3.11"
|
|
dependencies = [
|
|
"asyncpg>=0.29.0",
|
|
"python-dotenv>=1.0.0",
|
|
"openai>=1.0.0",
|
|
"pydantic>=2.0.0",
|
|
"rich>=13.0.0",
|
|
"langchain-text-splitters>=0.3.0",
|
|
"fastapi[standard]>=0.120.3",
|
|
"uvicorn>=0.38.0",
|
|
"wsproto>=1.0.0",
|
|
# Cap below 2.1: SQLAlchemy 2.1 switches the default `postgresql://` DBAPI
|
|
# from psycopg2 to psycopg (v3), which we don't ship — a bare install would
|
|
# fail migrations with "No module named 'psycopg'". Pin to the tested 2.0
|
|
# line (which keeps psycopg2 the default driver) until psycopg3 is adopted.
|
|
"sqlalchemy>=2.0.44,<2.1",
|
|
"alembic>=1.17.1",
|
|
"pgvector>=0.4.1",
|
|
"greenlet>=3.2.4,<3.4.0", # 3.4.0 lacks arm64 wheels for manylinux_2_41
|
|
"psycopg2-binary>=2.9.11",
|
|
"tiktoken>=0.12.0",
|
|
"httpx>=0.27.0",
|
|
"PyJWT[crypto]>=2.8.0",
|
|
"fastmcp>=3.2.0", # SSRF/path traversal, OAuth confused deputy, command injection fixes
|
|
"python-dateutil>=2.8.0",
|
|
# Two coupled reasons for these floors — keep all six pins moving together:
|
|
# (1) opentelemetry-exporter-prometheus calls
|
|
# MetricReader.__init__(otel_component_type=…), a kwarg added in
|
|
# opentelemetry-sdk 1.41.0 (open-telemetry/opentelemetry-python#4970).
|
|
# Without matched floors, pip resolves a new exporter against an older
|
|
# sdk and metric initialisation crashes at startup with
|
|
# "MetricReader.__init__() got an unexpected keyword argument
|
|
# 'otel_component_type'".
|
|
# (2) opentelemetry-proto <1.44 caps protobuf<7.0; 1.44.0 raised it to
|
|
# protobuf<8.0, which is what lets the protobuf pin below reach 7.x.
|
|
"opentelemetry-api>=1.44.0",
|
|
"opentelemetry-sdk>=1.44.0",
|
|
"opentelemetry-instrumentation-fastapi>=0.65b0",
|
|
"opentelemetry-exporter-prometheus>=0.65b0",
|
|
"opentelemetry-exporter-otlp-proto-http>=1.44.0",
|
|
"opentelemetry-semantic-conventions>=0.65b0",
|
|
"dateparser>=1.2.2",
|
|
"google-genai>=1.0.0",
|
|
"google-auth>=2.0.0",
|
|
"anthropic>=0.40.0",
|
|
"typer>=0.9.0",
|
|
"cohere>=5.0.0",
|
|
"litellm>=1.84.0", # 1.82.7/1.82.8 had a supply chain compromise (yanked); 1.83.0+ also fixes GHSA-jjhc-v7c2-5hh6 / GHSA-53mr-6c8q-9789 / GHSA-pq44-5pcq-4r5g / GHSA-8cjq-wjmh-q42r; 1.84.0 fixes GHSA-4xpc-pv4p-pm3w
|
|
"markitdown[pdf,docx,pptx,xlsx,xls]>=0.1.4", # File to markdown conversion
|
|
"obstore>=0.4.0", # S3/GCS/Azure object storage client (Rust-backed)
|
|
"winloop>=0.1.0; sys_platform == 'win32'",
|
|
"uvloop>=0.22.1; sys_platform != 'win32'",
|
|
# Transitive dependency security fixes
|
|
"pyasn1>=0.6.3", # DoS vulnerability fix
|
|
"urllib3>=2.7.0", # Decompression-bomb safeguards bypass + sensitive header forwarding fixes
|
|
"langchain-core>=1.2.22", # Path traversal in legacy load_prompt functions fix
|
|
"langsmith>=0.8.18", # GHSA-f4xh-w4cj-qxq8: arbitrary server-side file read in TracingMiddleware fix (supersedes >=0.6.3 SSRF tracing-header-injection floor)
|
|
"protobuf>=7.35.1", # JSON recursion depth bypass fix (>=6.33.5); requires otel>=1.44 (proto <1.44 caps protobuf<7.0)
|
|
"pillow>=12.3.0", # Multiple HIGH image parsing vulnerabilities fixed in 12.3.0
|
|
"cryptography>=48.0.1", # GHSA-537c-gmf6-5ccf: bundled-OpenSSL OOB read fix needs >=48.0.1. Prior <47 cap (47.0.0 SIGILL on ARM64 Docker/Podman, pyca/cryptography#14733) lifted — 47/48/49 verified importing + RSA sign/verify cleanly on linux/arm64 (Docker on Apple Silicon) and native arm64 macOS; upstream issue closed unconfirmed.
|
|
"filelock>=3.20.1", # TOCTOU race condition fix
|
|
"authlib>=1.6.9", # Account takeover/JWS header injection vulnerability fix
|
|
"pyjwt>=2.12.0", # Accepts unknown crit header extensions fix
|
|
"orjson>=3.11.6", # Unbounded recursion DoS fix
|
|
"python-multipart>=0.0.22", # Arbitrary file write via non-default configuration fix
|
|
"tornado>=6.5.5", # DoS multipart/incomplete cookie validation fix
|
|
"aiohttp>=3.13.3", # Multiple DoS vulnerabilities
|
|
"pygments>=2.20.0", # ReDoS via inefficient GUID regex fix
|
|
"claude-agent-sdk>=0.2.82",
|
|
"boto3>=1.42.74",
|
|
"croniter>=2.0.0", # Cron parsing for scheduled mental model refresh
|
|
"json-repair>=0.30.0", # Structural repair of malformed LLM JSON (last-resort parse fallback)
|
|
]
|
|
|
|
[project.optional-dependencies]
|
|
local-ml = [
|
|
# Local ML models for embeddings/reranking
|
|
"sentence-transformers>=3.3.0",
|
|
"transformers>=5.5.0", # ReDoS fixes; 5.5.0 clears GHSA-fgcw-684q-jj6r (LightGlue RCE)
|
|
# transformers enforces tokenizers<=0.23.0 with a runtime check, but has
|
|
# shipped metadata declaring a wider range than it actually enforces. Keep
|
|
# this cap: without it an in-place upgrade can pull tokenizers 0.23.1 and
|
|
# break local embeddings/reranker startup. See issue #2055.
|
|
"tokenizers>=0.22.0,<=0.23.0",
|
|
"torch>=2.6.0", # CVE fix for remote code execution
|
|
"einops>=0.8.2",
|
|
"flashrank>=0.2.0",
|
|
# Apple Silicon local inference — mlx publishes wheels only for
|
|
# macOS/Linux, not Windows, so gate on platform to let `uv sync
|
|
# --all-extras` resolve on win_amd64 runners.
|
|
"mlx>=0.31.0; sys_platform != 'win32'",
|
|
"mlx-lm>=0.31.1; sys_platform != 'win32'",
|
|
"safetensors>=0.6.2",
|
|
]
|
|
local-llm = [
|
|
# Built-in llama.cpp inference for fully offline operation
|
|
"llama-cpp-python[server]>=0.3.0",
|
|
"huggingface-hub>=0.20.0",
|
|
]
|
|
local-onnx = [
|
|
# In-process ONNX Runtime embeddings without an Ollama/TEI sidecar
|
|
"onnxruntime>=1.17.0",
|
|
"transformers>=5.5.0", # 5.5.0 clears GHSA-fgcw-684q-jj6r (LightGlue RCE)
|
|
"tokenizers>=0.22.0,<=0.23.0", # See issue #2055 (transformers caps tokenizers<=0.23.0)
|
|
"huggingface-hub>=0.20.0",
|
|
"numpy>=1.26.0",
|
|
]
|
|
embedded-db = [
|
|
"pg0-embedded>=0.14.2",
|
|
]
|
|
oracle = [
|
|
"oracledb>=2.5.0",
|
|
]
|
|
all = [
|
|
"hindsight-api-slim[local-ml,local-onnx,embedded-db]",
|
|
]
|
|
test = [
|
|
"pytest>=7.0.0",
|
|
"pytest-asyncio>=0.21.0",
|
|
"pytest-timeout>=2.4.0",
|
|
"pytest-xdist>=3.0.0",
|
|
"filelock>=3.20.1", # TOCTOU race condition fix
|
|
"testcontainers>=4.0.0",
|
|
]
|
|
|
|
[project.scripts]
|
|
hindsight-api = "hindsight_api.main:main"
|
|
hindsight-worker = "hindsight_api.worker.main:main"
|
|
hindsight-local-mcp = "hindsight_api.mcp_local:main"
|
|
hindsight-admin = "hindsight_api.admin.cli:main"
|
|
|
|
[tool.hatch.build.targets.wheel]
|
|
packages = ["hindsight_api"]
|
|
|
|
[tool.hatch.build.targets.wheel.sources]
|
|
"hindsight_api" = "hindsight_api"
|
|
|
|
[tool.hatch.build.targets.sdist]
|
|
include = [
|
|
"hindsight_api/**/*",
|
|
]
|
|
|
|
[tool.hatch.build]
|
|
include = [
|
|
"hindsight_api/**/*.py",
|
|
"hindsight_api/alembic/**/*",
|
|
]
|
|
|
|
[tool.pytest.ini_options]
|
|
log_cli = true
|
|
log_cli_level = "INFO"
|
|
log_cli_format = "%(asctime)s - %(levelname)s - %(name)s - %(message)s"
|
|
log_cli_date_format = "%Y-%m-%d %H:%M:%S"
|
|
addopts = "--timeout 300 -n 8 --dist loadgroup --durations=10 -v"
|
|
markers = [
|
|
"oracle: Oracle 23ai integration tests (require ORACLE_TEST_DSN env var)",
|
|
"hs_llm_mat: LLM minimum acceptance tests — run in CI matrix across multiple providers",
|
|
"hs_llm_core: Core pipeline tests that need a real LLM but only one provider",
|
|
"integration: Live external-API integration tests (require provider credentials; skipped without)",
|
|
"slow: Slow tests (minutes); not run in fast CI",
|
|
]
|
|
asyncio_mode = "auto"
|
|
asyncio_default_fixture_loop_scope = "function"
|
|
log_auto_indent = true
|
|
filterwarnings = [
|
|
"ignore:The @wait_container_is_ready decorator is deprecated:DeprecationWarning",
|
|
"ignore::RuntimeWarning:asyncio",
|
|
]
|
|
|
|
[dependency-groups]
|
|
dev = [
|
|
"pytest>=9.0.0",
|
|
"pytest-asyncio>=1.3.0",
|
|
"pytest-timeout>=2.4.0",
|
|
"pytest-xdist>=3.8.0",
|
|
"pytest-rerunfailures>=15.0",
|
|
"python-dotenv>=1.2.1",
|
|
"filelock>=3.20.1", # TOCTOU race condition fix
|
|
"ruff>=0.8.0",
|
|
"ty>=0.0.1",
|
|
"testcontainers>=4.0.0",
|
|
]
|
|
|
|
[tool.ruff]
|
|
line-length = 120
|
|
target-version = "py311"
|
|
|
|
[tool.ruff.lint]
|
|
# Tests are formatted (via `ruff format`) but excluded from lint rules, which
|
|
# are too noisy for test code (unused imports/vars, import ordering).
|
|
exclude = [
|
|
"tests/**",
|
|
"**/tests/**",
|
|
]
|
|
select = [
|
|
"E", # pycodestyle errors
|
|
"W", # pycodestyle warnings
|
|
"F", # Pyflakes
|
|
"I", # isort
|
|
"B021", # flake8-bugbear: f-string used as docstring (leaves __doc__ None)
|
|
]
|
|
ignore = [
|
|
"E501", # line too long (handled by formatter)
|
|
"E402", # module import not at top of file
|
|
"F811", # redefined while unused
|
|
"F821", # undefined name (forward references in type hints)
|
|
]
|
|
|
|
[tool.ruff.lint.isort]
|
|
known-third-party = ["alembic"]
|
|
|
|
[tool.ruff.format]
|
|
quote-style = "double"
|
|
indent-style = "space"
|
|
|
|
[tool.uv]
|
|
# Use explicit index for PyTorch to prevent the pytorch index from serving
|
|
# non-pytorch packages (e.g. markupsafe) with incompatible wheels
|
|
[[tool.uv.index]]
|
|
name = "pytorch-cpu"
|
|
url = "https://download.pytorch.org/whl/cpu"
|
|
explicit = true
|
|
|
|
[tool.uv.sources]
|
|
# Route torch to the CPU-only PyTorch index; everything else uses PyPI
|
|
torch = { index = "pytorch-cpu" }
|
|
|
|
[tool.ty]
|
|
# Type checking configuration
|
|
# ty is an extremely fast Python type checker from Astral (same team as ruff/uv)
|
|
|
|
[tool.ty.environment]
|
|
python-version = "3.11"
|
|
|
|
[tool.ty.src]
|
|
exclude = [
|
|
"tests/",
|
|
"hindsight_api/alembic/",
|
|
]
|
|
|
|
[tool.ty.rules]
|
|
# Disable noisy rules while keeping important ones
|
|
invalid-argument-type = "ignore" # False positives with **kwargs patterns
|
|
invalid-return-type = "ignore" # Often intentional in async code
|
|
invalid-parameter-default = "ignore" # Optional params with None default
|
|
possibly-missing-attribute = "ignore" # Common with Optional types
|
|
invalid-raise = "ignore" # False positives with exception tracking
|
|
call-non-callable = "ignore" # False positives with Optional types
|
|
invalid-key = "ignore" # Pydantic ConfigDict not understood
|
|
invalid-method-override = "ignore" # Intentional signature differences
|
|
unresolved-reference = "ignore" # Forward references not always resolved
|