Skip to content

Commit 3e6e4f5

Browse files
committed
Merge branch 'dev'
2 parents 555d302 + 5290a99 commit 3e6e4f5

122 files changed

Lines changed: 12522 additions & 1914 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ["main", "review", "review-1"]
6+
pull_request:
7+
8+
env:
9+
PIP_DISABLE_PIP_VERSION_CHECK: "1"
10+
11+
jobs:
12+
lint:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Check out
16+
uses: actions/checkout@v4
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.11"
21+
- name: Install toolchain
22+
run: |
23+
pip install uv
24+
uv pip install --system -e .
25+
uv pip install --system ruff pyright typeguard toml-sort yamllint
26+
- name: Lint and format checks
27+
run: |
28+
make fmt-check
29+
make protos-check
30+
- name: Docs guard
31+
env:
32+
BASE_REF: ${{ github.event.pull_request.base.sha || 'HEAD~1' }}
33+
run: make docs-guard
34+
35+
tests:
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Check out
39+
uses: actions/checkout@v4
40+
- name: Set up Python
41+
uses: actions/setup-python@v5
42+
with:
43+
python-version: "3.11"
44+
- name: Install dependencies
45+
run: |
46+
pip install uv
47+
uv pip install --system -e .
48+
uv pip install --system pytest
49+
- name: Run pytest
50+
run: make test

AGENTS.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Agent Instructions
2+
3+
## Documentation Workflow
4+
- After each batch of changes, add a `CHANGELOG.md` entry with an ISO 8601 date/time stamp in United States Eastern time (include the timezone code, e.g., `America/New_York` or `ET`) and developer-facing detail (files, modules, functions, variables, and rationale). Every commit should correspond to a fresh entry.
5+
- Maintain `README.md` as the canonical description of the project; update it whenever behaviour or workflows change. Archive older versions separately when requested.
6+
- Keep the `docs/` wiki and provisioning guides (`SETUP.md`, `ENVIRONMENT_NEEDS.md`) in sync with code updates; add or revise the
7+
relevant page whenever features, modules, or workflows change.
8+
- After each iteration, refresh `ISSUES.md`, `SOT.md`, `PLAN.md`, `RECOMMENDATIONS.md`, `TODO.md`, and related documentation to stay in sync with the codebase.
9+
- Ensure `TODO.md` retains the `Completed`, `Priority Tasks`, and `Recommended Waiting for Approval Tasks` sections, moving finished items under `Completed` at the end of every turn.
10+
- Make every task in `TODO.md` atomic: each entry must describe a single, self-contained deliverable with enough detail to execute and verify without cross-referencing additional context.
11+
- Update `RESUME_NOTES.md` at the end of every turn so the next session starts with accurate context.
12+
- When beginning a turn, review `README.md`, `PROJECT.md`, `PLAN.md`, `RECOMMENDATIONS.md`, `ISSUES.md`, `SOT.md`, `ROADMAP.md`, `PLANNING_THOUGHTS.md`, and the `research/` wiki to harvest new actionable work. Maintain at least ten quantifiable, prioritised items in the `Priority Tasks` section of `TODO.md`, adding context or links when needed.
13+
- Keep `ROADMAP.md`, `PLANNING_THOUGHTS.md`, and the `research/` docs aligned with each iteration when new discoveries or decisions occur.
14+
- After completing any task, immediately update `TODO.md`, check for the next actionable item, and continue iterating until all unblocked `Priority Tasks` are exhausted for the session.
15+
- Continuously loop through planning and execution: finish a task, document it, surface new follow-ups, and resume implementation so long as environment blockers allow. If extra guidance would improve throughput, extend these instructions proactively.
16+
17+
## Style Guidelines
18+
- Use descriptive Markdown headings starting at level 1 for top-level documents.
19+
- Keep lines to 120 characters or fewer when practical.
20+
- Prefer bullet lists for enumerations instead of inline commas.

CHANGELOG.md

Lines changed: 288 additions & 0 deletions
Large diffs are not rendered by default.

CLEANUP.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Cleanup Plan for Temporary Workarounds
2+
3+
The following actions should be executed once the development environment consistently provides internet access and all
4+
optional dependencies can be installed. Each item references the affected files, the temporary workaround currently in
5+
place, and the exact remediation steps required to bring the implementation in line with production expectations.
6+
7+
## Compatibility Layers
8+
9+
### Replace Pydantic Shim (Completed)
10+
- **Files**: `meshmind/_compat/pydantic.py`, modules importing from `meshmind._compat.pydantic`.
11+
- **Status**: Completed – the shim has been removed, `pydantic>=2.11` is a required dependency, and all models/tests now consume the official APIs directly.
12+
13+
### Retire FastAPI Stub (Completed)
14+
- **Files**: `meshmind/api/rest.py`, `meshmind/api/service.py`, `docs/api.md`, `SETUP.md`.
15+
- **Status**: Completed – the REST layer now requires FastAPI, tests rely on
16+
`fastapi.testclient.TestClient`, and documentation reflects the production
17+
stack.
18+
19+
### Replace gRPC Dataclass Shim (Completed)
20+
- **Files**: `meshmind/api/grpc.py`, `meshmind/protos/memory_service.proto`, `meshmind/tests/test_service_interfaces.py`, `docs/api.md`.
21+
- **Status**: Completed – protobuf definitions now live under `meshmind/protos`, generated modules back the Python stub, setup scripts install `grpcio`/`grpcio-tools`, and tests exercise the canonical schema.
22+
23+
### Promote gRPC Server Implementation
24+
- **Files**: `meshmind/api/grpc.py`, `meshmind/api/grpc_server.py`, CLI entry points,
25+
integration tests.
26+
- **Current State**: An asyncio server helper and CLI (`meshmind serve-grpc`) now
27+
run the service; Docker Compose provisions a gRPC container. Integration tests
28+
against a live server remain outstanding.
29+
- **Action**:
30+
1. Add integration tests (possibly using `grpc.aio.insecure_channel`) that cover
31+
ingestion, search, and memory counts against the running server.
32+
2. Publish generated client artifacts for downstream consumers once
33+
infrastructure is available.
34+
35+
## Task Scheduling Workarounds
36+
37+
### Remove Celery Dummy App and Beat Fallback (Completed)
38+
- **Files**: `meshmind/tasks/celery_app.py`, `meshmind/tasks/scheduled.py`.
39+
- **Status**: Completed – Celery is a required dependency, the runtime imports the
40+
real app/beat scheduler, and docker-compose stacks provision Redis for workers.
41+
42+
## Testing Fakes
43+
44+
### Evaluate Graph/Embedding/Test Fakes
45+
- **Files**: `meshmind/testing/fakes.py`, `meshmind/tests/conftest.py`, `meshmind/tests/test_*`.
46+
- **Current State**: In-memory drivers and dummy encoders enable offline unit tests.
47+
- **Action**:
48+
1. Keep unit-test fakes for isolation but ensure parallel integration suites use live services.
49+
2. Document expectations in `docs/testing.md` and mark fakes clearly as test-only utilities.
50+
3. Remove any production code paths that accidentally import fakes.
51+
52+
### Replace Memgraph Client Mock
53+
- **Files**: `meshmind/tests/test_memgraph_driver.py`.
54+
- **Current State**: Monkeypatches a fake `mgclient` module for driver tests.
55+
- **Action**:
56+
1. Install `pymgclient` and run tests against a dockerized Memgraph instance.
57+
2. Retain the fake only for negative/offline coverage; guard it behind an explicit fixture flag.
58+
59+
## Observability and Telemetry
60+
61+
### Confirm Logging Metrics Alignment
62+
- **Files**: `meshmind/core/observability.py`, `meshmind/pipeline/*`, `docs/telemetry.md`.
63+
- **Current State**: Logging/metrics rely on standard library fallbacks.
64+
- **Action**:
65+
1. Integrate preferred observability stack (e.g., OpenTelemetry) once dependencies are greenlit.
66+
2. Remove or demote placeholders that mimic external exporters.
67+
68+
## Tooling and Automation
69+
70+
### Finalize Setup Scripts
71+
- **Files**: `run/install_setup.sh`, `run/maintenance_setup.sh`.
72+
- **Current State**: Scripts install packages opportunistically.
73+
- **Action**:
74+
1. Review installed package list after environment unblock and remove conditional guards.
75+
2. Ensure scripts configure CLI tools (e.g., `grpcurl`, `neo4j-admin`) that were previously skipped offline.
76+
77+
### Lock Dependency Graph
78+
- **Files**: `pyproject.toml`, `uv.lock`.
79+
- **Current State**: Lockfile may exclude previously unavailable packages.
80+
- **Action**:
81+
1. Regenerate `uv.lock` after all dependencies are installed.
82+
2. Commit the updated lockfile and note differences in `CHANGELOG.md`.
83+

DISCREPANCIES.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# README vs Implementation Discrepancies
2+
3+
## Overview
4+
- The legacy README has been superseded by `README.md`, which now reflects the implemented feature set.
5+
- The current codebase delivers extraction, preprocessing, triplet persistence, CRUD helpers, and expanded retrieval strategies
6+
that were missing when the README was written.
7+
- Remaining gaps primarily involve pushing retrieval workloads into the graph backend, exporting observability to external sinks, and automated infrastructure provisioning.
8+
9+
## API Surface
10+
-`MeshMind` now exposes CRUD helpers (`create_memory`, `update_memory`, `delete_memory`, `list_memories`, triplet helpers)
11+
that the README referenced implicitly.
12+
- ✅ Triplet storage routes through `store_triplets` and `MemoryManager.add_triplet`, calling `GraphDriver.upsert_edge`.
13+
- ⚠️ The README still references `register_entity`, `register_allowed_predicates`, and `add_predicate`; predicate management is
14+
handled automatically but there is no public API matching those method names.
15+
- ⚠️ README snippets showing `mesh_mind.store_memory(memory)` should be updated to call `store_memories([memory])` or the new
16+
CRUD helpers.
17+
18+
## Retrieval Capabilities
19+
- ✅ Vector-only, regex, exact-match, hybrid, BM25, fuzzy, and optional LLM rerank searches exist in `meshmind.retrieval.search`
20+
and are surfaced through `MeshMind` helpers.
21+
- ⚠️ README implies retrieval queries the graph directly. Search helpers now fetch candidates from the configured driver when no
22+
list is supplied but still score results in Python; Memgraph/Neo4j-native search remains future work.
23+
- ⚠️ Named helpers like `search_facts` or `search_procedures` never existed; the README should reference the dispatcher plus
24+
specialized helpers now available.
25+
26+
## Data & Relationship Modeling
27+
- ✅ Predicates are persisted automatically when storing triplets and tracked in `PredicateRegistry`.
28+
- ⚠️ README examples that look up subjects/objects by name still do not match the implementation, which expects UUIDs. Add
29+
documentation explaining how to resolve names to UUIDs before storing edges.
30+
- ⚠️ Consolidation and expiry run via Celery jobs; README narratives should highlight that heuristics require further validation even though persistence is now wired up.
31+
32+
## Configuration & Dependencies
33+
-`README.md` and `ENVIRONMENT_NEEDS.md` document required environment variables, dependency guards, and setup steps.
34+
- ⚠️ README still omits optional tooling now required by the Makefile/CI (ruff, pyright, typeguard, toml-sort, yamllint);
35+
highlight these prerequisites more prominently.
36+
- ✅ Python version support in `pyproject.toml` now pins `>=3.11,<3.13`, matching the dependency landscape documented in the README.
37+
38+
## Example Code Paths
39+
- ✅ Updated example scripts demonstrate extraction, triplet creation, and multiple retrieval strategies.
40+
- ⚠️ Legacy README code that instantiates custom Pydantic entities remains inaccurate; extraction returns `Memory` objects and
41+
validates `entity_label` names only.
42+
- ⚠️ Search examples should be updated to show the new helper functions and optional rerank usage instead of nonexistent
43+
`search_facts`/`search_procedures` calls.
44+
45+
## Tooling & Operations
46+
- ✅ Makefile and CI workflows now exist, aligning with README promises about automation once the README is refreshed.
47+
- ✅ Docker Compose now provisions Memgraph, Redis, and a Celery worker; README sections should highlight the workflow and
48+
caveats for environments lacking container tooling.
49+
- ⚠️ Celery tasks still depend on optional infrastructure; README should clarify that heuristics and scheduling need production hardening even though persistence now works.
50+
51+
## Documentation State
52+
- Continue promoting `README.md` as the authoritative guide and propagate updates to supporting docs
53+
(`SOT.md`, `PLAN.md`, `ENVIRONMENT_NEEDS.md`, `docs/`).

DUMMIES.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Dummies and Compatibility Artifacts
2+
3+
The following table tracks all temporary shims, fake implementations, and stub services that were introduced while the
4+
sandbox lacked internet access or external infrastructure. Each row notes what the component does today and the
5+
recommended next step now that full dependencies can be installed.
6+
7+
| Component | Location | Purpose | Current Usage | Recommended Action |
8+
| --- | --- | --- | --- | --- |
9+
| gRPC stub implementation | `meshmind/api/grpc.py` (`GrpcServiceStub` + generated protobuf helpers) | Provides an in-process service implementation backed by the canonical proto schema so tests can exercise the service layer without spinning up gRPC infrastructure. | Unit tests and docs rely on the stub while production traffic should flow through the new asyncio helpers in `meshmind.api.grpc_server`. | Keep the stub for tests; package the new server behind a CLI entry point and retire any ad-hoc wrappers once infrastructure is provisioned. |
10+
| Fake graph/storage drivers | `meshmind/testing/fakes.py` (`FakeMemgraphDriver`, `FakeRedisBroker`, `FakeEmbeddingEncoder`) | Provide offline stand-ins for Memgraph, Redis, and embedding models. | Pytest fixtures and documentation rely on these for isolation. | Keep as long as offline tests are desired; supplement with integration suites that use real services. |
11+
| Fake LLM client | `meshmind/testing/fakes.py` (`FakeLLMClient`) | Records per-request overrides and emits deterministic responses so tests exercise reranking without installing the OpenAI SDK. | Service/interface tests (`meshmind/tests/test_service_interfaces.py`, `test_client.py`) and the CLI fixtures inject this stub when `openai` is unavailable. | Keep for unit tests; add integration tests with real providers once keys and network access are provisioned. |
12+
| Dummy encoder fixture | `meshmind/tests/conftest.py` (`dummy_encoder`) and dependent tests | Supplies a lightweight embedding encoder for search tests. | Used across retrieval and service tests to avoid network calls. | Keep for unit tests; add integration coverage with real encoders once APIs are configured. |
13+
| Fake mgclient module | `meshmind/tests/test_memgraph_driver.py` (monkeypatch of `mgclient`) | Simulates the Memgraph client so driver code runs without the native binary. | Enables driver unit tests without installing `mgclient`. | Replace with real `mgclient`-backed tests once package access is ensured; keep shim for fallback coverage. |
14+
15+
## Retired Items
16+
17+
- **Pydantic compatibility shim (`meshmind/_compat/pydantic.py`)** – Removed now that the project installs `pydantic>=2.11` during setup. All models import directly from Pydantic and tests confirm no fallback is required.
18+
- **FastAPI REST stub (`meshmind/api/rest.py`)** – Removed in favour of the concrete FastAPI application now that `fastapi` is a required dependency and tests exercise it via `TestClient`.
19+
- **Celery dummy app and beat fallback (`meshmind/tasks/celery_app.py`, `meshmind/tasks/scheduled.py`)** – Retired because Celery is now installed by default; the real app and `crontab` integration are always imported.

Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM python:3.11-slim
2+
3+
ENV PIP_NO_CACHE_DIR=1 \
4+
PYTHONDONTWRITEBYTECODE=1 \
5+
PYTHONUNBUFFERED=1
6+
7+
WORKDIR /app
8+
9+
RUN apt-get update \
10+
&& apt-get install -y --no-install-recommends \
11+
build-essential \
12+
cmake \
13+
libssl-dev \
14+
libkrb5-dev \
15+
curl \
16+
git \
17+
&& rm -rf /var/lib/apt/lists/*
18+
19+
COPY . /app
20+
21+
RUN pip install uv \
22+
&& uv pip install --system -e .[dev,docs,testing]
23+
24+
CMD ["bash"]

ENVIRONMENT_NEEDS.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Tasks for Human Project Manager
2+
3+
- Keep the Python package layer aligned with the project extras during base image
4+
refreshes. The `run/install_setup.sh` and `run/maintenance_setup.sh` scripts now
5+
install the full optional stack (neo4j driver, `pymgclient`, Redis, Celery extras,
6+
FastAPI/Uvicorn, LLM tooling, and developer linters/testers). Ensure cached
7+
environments either run the maintenance script or bake these dependencies into the
8+
image so cold starts do not regress coverage.
9+
- Provide system-level build dependencies for the graph drivers (e.g., `build-essential`,
10+
`cmake`, `libssl-dev`, `libkrb5-dev`) so `pymgclient` (and its `mgclient` module) install cleanly.
11+
- Provision external services and credentials (compose files now exist under the project
12+
root and `meshmind/tests/docker/`):
13+
- Neo4j instance reachable from the execution environment with `NEO4J_URI`,
14+
`NEO4J_USERNAME`, `NEO4J_PASSWORD` (defaults to `neo4j` / `meshminD123`).
15+
- Memgraph instance with `MEMGRAPH_URI`, `MEMGRAPH_USERNAME`, `MEMGRAPH_PASSWORD`
16+
(anonymous access acceptable locally).
17+
- Redis instance with `REDIS_URL`.
18+
- LLM provider API key (`LLM_API_KEY` or fallback `OPENAI_API_KEY`) plus any
19+
alternative base URLs/models required for OpenRouter, Azure, or Google-hosted
20+
endpoints so the new `llm_client` overrides can be exercised end-to-end.
21+
- Default maintenance retry configuration (`MAINTENANCE_MAX_ATTEMPTS`, `MAINTENANCE_BASE_DELAY_SECONDS`) tuned for the deployed graph backend; surface recommended values once integration tests run against live clusters. *(Future refinement request once infra is available.)*
22+
- Supply datasets/fixtures (future request) representing large knowledge graphs to
23+
stress-test consolidation heuristics and pagination under load.
24+
- Maintain outbound package download access to PyPI and vendor repositories; this
25+
session confirmed package installation works when the network is open, and future
26+
sessions need the same capability to refresh locks or install new optional
27+
integrations.
28+
- Enable Docker or container runtime access (future request) so the provided
29+
`docker-compose.yml` files can run inside this environment; alternatively, provision
30+
remote services accessible to CI.
31+
- Document credential management procedures and rotation cadence so secrets stay current.
32+
- Keep gRPC tooling (`grpcio`, `grpcio-tools`, protobuf compiler) available in cached environments; the proto definitions now
33+
back the production stubs and runtime server (`meshmind.api.grpc_server`). `scripts/generate_protos.py` regenerates bindings
34+
and `scripts/check_protos.py` enforces drift in CI, so ensure the toolchain runs successfully during maintenance scripts.

0 commit comments

Comments
 (0)