Skip to content

fix: CI lint debt + deps + quickstart bug (green CI)#33

Open
RBKunnela wants to merge 4 commits into
mainfrom
fix/ci-lint-drift
Open

fix: CI lint debt + deps + quickstart bug (green CI)#33
RBKunnela wants to merge 4 commits into
mainfrom
fix/ci-lint-drift

Conversation

@RBKunnela

@RBKunnela RBKunnela commented Jun 30, 2026

Copy link
Copy Markdown
Owner

Summary

Clears accumulated CI lint debt, reconciles dependency metadata, and fixes a real bug that broke the library's headline entry point. Goal: green CI across the supported Python matrix.

Changes (4 commits)

  1. fix(core): remove doubled @classmethod on ALMA.quickstart (f008bfe) — the important one. ALMA.quickstart() — the entry point featured at the top of the README — carried a doubled @classmethod decorator. On Python 3.13+ this raised at call time, so the documented "first thing you run" was broken for anyone on a current interpreter. Removed the duplicate decorator; ALMA.quickstart() works again.
  2. fix(lint): resolve 11 ruff errors blocking CI (c020e64) — 11 ruff violations that were failing the lint gate.
  3. fix(mcp): derive server_version from alma.__version__ (f8330ad) — MCP server version is now sourced from alma.__version__ instead of a hardcoded literal, so it cannot drift from the package version.
  4. chore(deps): reconcile requirements.txt with pyproject and register pytest marker (5185fa2) — aligned requirements.txt with pyproject, and registered the previously-unknown pytest marker so the test run is warning-clean.

Validation

  • Tests pass locally: 1819/226 unit, 227 integration.
  • CI validates across Python 3.10-3.12.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a new optional tokenizer install extra and included it in the all-in-one install option.
    • Added an integration test marker for clearer test selection.
  • Bug Fixes

    • Improved setup and diagnostics messages during initialization, PostgreSQL setup, and test/doctor commands.
    • Version info for the server now follows the installed app version automatically.
  • Chores

    • Updated dependency guidance and reorganized package requirements to better match installation extras.

RBKunnela and others added 4 commits June 30, 2026 18:49
Auto-fixed 7 (unsorted imports in cli.py, 5x F541 f-strings without
placeholders) and manually fixed the rest:
- B904 in core.py: re-raise ImportError with `from err` to preserve chain
- F401 in cli.py: replace unused `import faiss` with importlib.util.find_spec
  availability check (preserves doctor-command semantics)
- F841 in cli.py: drop two unused `result` assignments

`ruff check alma/ tests/` and `ruff format --check alma/ tests/` now pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The MCP server hardcoded server_version="0.6.0" while the package is at
0.10.0. Default to alma.__version__ so the version can no longer drift.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ytest marker

- Remove torch>=2.0.0 from requirements.txt: not imported directly, it is a
  transitive dependency of sentence-transformers (the [local] extra), so the
  direct pin only created drift.
- Add a [tokenizer] extra (tiktoken>=0.5.0) for alma/utils/tokenizer.py, which
  is an optional capability with graceful fallback; fold it into [all].
- Make pyproject.toml authoritative; rewrite requirements.txt as a documented
  convenience mirror that points to the extras.
- Register the `integration` pytest marker to kill PytestUnknownMarkWarning.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The stacked @classmethod decorators made ALMA.quickstart() raise
"'classmethod' object is not callable" on Python 3.13+, breaking the
README's headline zero-config entry point. Verified callable after the fix.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

CLI messaging, warning suppression, and faiss detection are refactored; ALMA.quickstart adds exception chaining on ImportError; the MCP server derives its version from __version__; a new tokenizer optional extra (tiktoken>=0.5.0) is added to pyproject.toml; and requirements.txt is reorganized to mirror pyproject.toml extras.

Changes

CLI, Core, and Packaging Updates

Layer / File(s) Summary
Packaging: tokenizer extra and requirements reorganization
pyproject.toml, requirements.txt
Adds tiktoken>=0.5.0 as a new tokenizer optional extra, includes it in all, adds an integration pytest marker, and reorganizes requirements.txt with updated guidance, removing the direct torch>=2.0.0 pin.
MCP server dynamic version
alma/mcp/server.py
Imports __version__ from alma and uses it as the default server_version in ALMAMCPServer.__init__ instead of the hardcoded "0.6.0".
core.py: exception chaining in quickstart
alma/core.py
Catches ImportError as err and re-raises with from err chaining in ALMA.quickstart; reorders local imports; normalizes @classmethod placement.
CLI refactors: warnings, messaging, faiss detection, argparse
alma/cli.py
Adds importlib.util import; rewrites sentence_transformers warning filters to explicit multiline calls; updates init config-exists message, local-embeddings hint, and PostgreSQL post-config instructions; replaces try-import faiss with find_spec; improves test missing-config output; reformats retrieve and pg-setup subprocess calls; expands argparse wiring to multiline calls.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: lint cleanup, dependency alignment, and the quickstart fix.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ci-lint-drift

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request cleans up formatting, reorganizes dependencies in requirements.txt and pyproject.toml, and updates the MCP server to use the package's version dynamically. It also removes a duplicate @classmethod decorator in alma/core.py and changes the faiss diagnostic check in alma/cli.py to use importlib.util.find_spec. Feedback suggests reverting the faiss check to a direct import to ensure compiled C++ extensions load correctly, and adding the --no-password flag to the psql subprocess call to prevent the CLI from hanging on hidden password prompts.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread alma/cli.py
Comment on lines 15 to 17
import argparse
import importlib.util
import os

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If we revert the faiss check to use a direct import, importlib.util is no longer needed in this file and can be removed to keep the imports clean.

Suggested change
import argparse
import importlib.util
import os
import argparse
import os

Comment thread alma/cli.py
Comment on lines +223 to +230
if importlib.util.find_spec("faiss") is not None:
_check("faiss (fast vector search)", True)
except ImportError:
_check("faiss (fast vector search)", False,
"pip install 'alma-memory[local]' — uses numpy fallback until then")
else:
_check(
"faiss (fast vector search)",
False,
"pip install 'alma-memory[local]' — uses numpy fallback until then",
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using importlib.util.find_spec("faiss") only checks for the presence of the module files on disk, but does not attempt to load the module. Since faiss relies heavily on compiled C++ extensions, it is common for imports to fail due to missing system shared libraries (e.g., libgomp) even if the package is installed. Reverting to a direct import faiss wrapped in a try/except block (with a # noqa: F401 comment to satisfy Ruff) ensures that the diagnostic check actually verifies the library is fully functional.

Suggested change
if importlib.util.find_spec("faiss") is not None:
_check("faiss (fast vector search)", True)
except ImportError:
_check("faiss (fast vector search)", False,
"pip install 'alma-memory[local]' — uses numpy fallback until then")
else:
_check(
"faiss (fast vector search)",
False,
"pip install 'alma-memory[local]' — uses numpy fallback until then",
)
try:
import faiss # noqa: F401
_check("faiss (fast vector search)", True)
except ImportError:
_check(
"faiss (fast vector search)",
False,
"pip install 'alma-memory[local]' — uses numpy fallback until then",
)

Comment thread alma/cli.py
Comment on lines +445 to 458
subprocess.run(
[
"psql",
f"--host={host}",
f"--port={port}",
f"--dbname={database}",
f"--username={user}",
"--command",
PG_SETUP_SQL,
],
capture_output=True,
text=True,
check=True,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since subprocess.run is called with capture_output=True, any interactive prompts (such as a password prompt from psql if the password is not set or cached) will be hidden from the user, causing the CLI to hang indefinitely. Adding the --no-password (or -w) flag to the psql command ensures that it fails immediately with a clear error message instead of hanging when a password is required but not provided.

Suggested change
subprocess.run(
[
"psql",
f"--host={host}",
f"--port={port}",
f"--dbname={database}",
f"--username={user}",
"--command",
PG_SETUP_SQL,
],
capture_output=True,
text=True,
check=True,
)
subprocess.run(
[
"psql",
"--no-password",
f"--host={host}",
f"--port={port}",
f"--dbname={database}",
f"--username={user}",
"--command",
PG_SETUP_SQL,
],
capture_output=True,
text=True,
check=True,
)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@alma/cli.py`:
- Around line 147-152: The setup hint in the CLI output is using the wrong
option name, so users copying it will fail before running pg-setup. Update the
pg-setup message in alma.cli.main() to use the actual registered flag name from
the parser, matching the --database argument instead of --db, and keep the rest
of the command text unchanged.
- Around line 223-230: The FAISS availability check in the CLI doctor path is
only using find_spec, which can report a false positive even when importing
faiss would fail. Update the logic in the doctor check block to perform an
actual import of faiss and treat ImportError as unavailable, so the _check call
reports the numpy fallback path correctly; use the existing _check helper in
alma.cli to keep the behavior consistent.

In `@pyproject.toml`:
- Line 102: The project.optional-dependencies.all entry is missing the
quickstart extra, so update the all extras list in pyproject.toml to include
quickstart alongside the existing optional groups. Make the change in the
optional-dependencies definition for all so that pip install alma-memory[all]
pulls in the complete set of extras.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: de8e3577-0544-4390-ad8f-d8f724342924

📥 Commits

Reviewing files that changed from the base of the PR and between 164d2e3 and f008bfe.

📒 Files selected for processing (5)
  • alma/cli.py
  • alma/core.py
  • alma/mcp/server.py
  • pyproject.toml
  • requirements.txt

Comment thread alma/cli.py
Comment on lines +147 to +152
print(
f" {_yellow('!')} Set password: export ALMA_DB_PASSWORD='your-password'"
)
print(
f" {_yellow('!')} Enable pgvector: alma pg-setup --host {host} --port {port} --db {database} --user {user}"
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Use the actual CLI flag in this setup command.

Line 151 prints --db, but main() only registers --database. Copy/pasting this instruction currently fails before pg-setup runs.

Suggested fix
-            f"  {_yellow('!')}  Enable pgvector: alma pg-setup --host {host} --port {port} --db {database} --user {user}"
+            f"  {_yellow('!')}  Enable pgvector: alma pg-setup --host {host} --port {port} --database {database} --user {user}"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
print(
f" {_yellow('!')} Set password: export ALMA_DB_PASSWORD='your-password'"
)
print(
f" {_yellow('!')} Enable pgvector: alma pg-setup --host {host} --port {port} --db {database} --user {user}"
)
print(
f" {_yellow('!')} Set password: export ALMA_DB_PASSWORD='your-password'"
)
print(
f" {_yellow('!')} Enable pgvector: alma pg-setup --host {host} --port {port} --database {database} --user {user}"
)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@alma/cli.py` around lines 147 - 152, The setup hint in the CLI output is
using the wrong option name, so users copying it will fail before running
pg-setup. Update the pg-setup message in alma.cli.main() to use the actual
registered flag name from the parser, matching the --database argument instead
of --db, and keep the rest of the command text unchanged.

Comment thread alma/cli.py
Comment on lines +223 to +230
if importlib.util.find_spec("faiss") is not None:
_check("faiss (fast vector search)", True)
except ImportError:
_check("faiss (fast vector search)", False,
"pip install 'alma-memory[local]' — uses numpy fallback until then")
else:
_check(
"faiss (fast vector search)",
False,
"pip install 'alma-memory[local]' — uses numpy fallback until then",
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the relevant section and imports
python3 - <<'PY'
from pathlib import Path
p = Path('alma/cli.py')
lines = p.read_text().splitlines()
for start, end in [(1, 80), (200, 250)]:
    print(f"\n--- {p}:{start}-{end} ---")
    for i in range(start, min(end, len(lines)) + 1):
        print(f"{i:4d}: {lines[i-1]}")
PY

# Find all faiss references in the repo
rg -n --hidden --glob '!**/.git/**' '\bfaiss\b' alma

Repository: RBKunnela/ALMA-memory

Length of output: 5069


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect how faiss is consumed in the storage backend
python3 - <<'PY'
from pathlib import Path
p = Path('alma/storage/sqlite_local.py')
lines = p.read_text().splitlines()
for start, end in [(1, 90), (450, 590)]:
    print(f"\n--- {p}:{start}-{end} ---")
    for i in range(start, min(end, len(lines)) + 1):
        print(f"{i:4d}: {lines[i-1]}")
PY

# Demonstrate that find_spec can succeed while import fails
python3 - <<'PY'
import importlib.util
import importlib
import tempfile
import os
import sys
from pathlib import Path

with tempfile.TemporaryDirectory() as d:
    p = Path(d)
    (p / "brokenmod.py").write_text("raise ImportError('simulated shared library/ABI failure')\n")
    sys.path.insert(0, d)
    try:
        print("find_spec:", importlib.util.find_spec("brokenmod") is not None)
        try:
            importlib.import_module("brokenmod")
            print("import: succeeded")
        except Exception as e:
            print("import:", type(e).__name__, str(e))
    finally:
        sys.path.remove(d)
PY

Repository: RBKunnela/ALMA-memory

Length of output: 9855


Import FAISS instead of checking only for a spec

find_spec("faiss") can report success even when the module fails to import, so alma doctor can show a false positive. Use an actual import and fall back to the numpy path on ImportError.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@alma/cli.py` around lines 223 - 230, The FAISS availability check in the CLI
doctor path is only using find_spec, which can report a false positive even when
importing faiss would fail. Update the logic in the doctor check block to
perform an actual import of faiss and treat ImportError as unavailable, so the
_check call reports the numpy fallback path correctly; use the existing _check
helper in alma.cli to keep the behavior consistent.

Comment thread pyproject.toml
]
all = [
"alma-memory[local,azure,postgres,qdrant,chroma,pinecone,mcp,rag,observability,dev]",
"alma-memory[local,azure,postgres,qdrant,chroma,pinecone,mcp,rag,tokenizer,observability,dev]",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: List all optional dependency extras defined in pyproject.toml and compare against 'all'

# Extract all extra names from [project.optional-dependencies]
python3 -c "
import tomllib
with open('pyproject.toml', 'rb') as f:
    data = tomllib.load(f)
opt = data.get('project', {}).get('optional-dependencies', {})
all_extras = set(opt.keys())
print('Defined extras:', sorted(all_extras))
all_entry = opt.get('all', [''])[0] if 'all' in opt else ''
included = set()
if all_entry:
    # Parse bracket contents like alma-memory[...]
    import re
    m = re.search(r'\[(.*?)\]', all_entry)
    if m:
        included = set(x.strip() for x in m.group(1).split(','))
print('In [all]:', sorted(included))
missing = all_extras - included - {'all'}
print('Missing from [all]:', sorted(missing) if missing else 'None')
"

Repository: RBKunnela/ALMA-memory

Length of output: 469


Add quickstart to [all] project.optional-dependencies.all is missing the quickstart extra, so pip install alma-memory[all] does not include the full optional set.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pyproject.toml` at line 102, The project.optional-dependencies.all entry is
missing the quickstart extra, so update the all extras list in pyproject.toml to
include quickstart alongside the existing optional groups. Make the change in
the optional-dependencies definition for all so that pip install
alma-memory[all] pulls in the complete set of extras.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant