Skip to content

Repo review + fixes for 3 broken commands (vec reindex, vsearch, dream-cycle) - #171

Draft
TSchonleber wants to merge 3 commits into
mainfrom
claude/repo-review-action-plan-igubb8
Draft

Repo review + fixes for 3 broken commands (vec reindex, vsearch, dream-cycle)#171
TSchonleber wants to merge 3 commits into
mainfrom
claude/repo-review-action-plan-igubb8

Conversation

@TSchonleber

@TSchonleber TSchonleber commented Aug 6, 2026

Copy link
Copy Markdown
Owner

What does this PR do?

Two things, from a full sweep of the open PRs and issues:

  1. docs/REPO_REVIEW_ACTION_PLAN.md — triage of all 18 open PRs and 9 open
    issues @ c634808, with a prioritized land/fix/close order.

  2. Fixes the three P0 bugs the review surfaced — each of which made a
    documented command completely non-functional and had no PR:

    Issue Command Root cause Fix
    [Bug] vec reindex crashes — ImportError: cannot import name 'sample_db_embedding_widths' from agentmemory.embeddings #160 brainctl vec reindex sample_db_embedding_widths imported + called in _impl.py but never definedImportError on every run Implement it in embeddings.py: probe float32 widths of a sample of vec_memories rows, cross-check against the DDL-declared dim so a destructive DROP+CREATE won't paper over a mixed-width/corrupt index without --force.
    [Bug] vsearch aborts on a missing vec table instead of skipping it (vec_events/vec_context are never created) #161 brainctl vsearch default tables include events/context, but vec_events/vec_context are never created → one missing table aborts the whole command Guard _vsearch_table against OperationalError for an absent vec table and return [] for that source, so results from vec_memories still surface.
    [Bug] dream-cycle NREM crashes: offset-naive vs offset-aware datetime subtraction in run_hebbian_pass #168 dream-cycle / dream-daemon Hebbian pass diffs a naive datetime.now() against aware-UTC created_atTypeError: can't subtract offset-naive and offset-aware datetimes Normalize parse_ts to always return aware UTC and coerce a naive now to aware UTC in days_since, so the subtraction is always aware − aware.

Why?

All three commands are dead on any real database — confirmed against the source
at c634808. Details and the rest of the backlog triage are in the plan doc.

How to test

python3 -m pytest tests/test_datetime_tz_normalization.py \
                  tests/test_embedding_width_probe.py \
                  tests/test_vsearch_missing_vec_table.py -q   # 13 new tests
# Touched-module regression set stays green:
python3 -m pytest tests/test_vec.py tests/test_mcp_tools_vsearch.py \
                  tests/test_hippocampus_resolve_contradictions.py -q

Follow-ups (called out, not done here)

Checklist

  • python3 -m py_compile passes on all touched modules
  • New behavior has tests (13 new; 60 green across touched modules)
  • No user-facing README change needed (bug fixes restore documented behavior)

Fixes #160
Fixes #161
Fixes #168

🤖 Generated with Claude Code

https://claude.ai/code/session_018eUi7mmueAJFfBssEezPiP

claude added 2 commits August 6, 2026 18:55
Triage of 18 open PRs and 9 open issues against main @ c634808.

Key findings:
- 3 documented commands are fully broken with no PR yet: vec reindex
  (#160, missing sample_db_embedding_widths), vsearch (#161, vec_events/
  vec_context never created), dream-cycle (#168, naive-vs-aware datetime
  crash in run_hebbian_pass). Flagged P0.
- 3 tested fixes ready to land: #166/#167 (FTS, with a merge-order
  dependency #166->#167) and #170 (MCP extra error).
- CI unrun on the 3 fork PRs (first-time-contributor gating).
- 10 Dependabot PRs safe to batch-merge; 4 stale drafts need a call.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018eUi7mmueAJFfBssEezPiP
Implements the three P0 fixes identified in the repo review.

#160 vec reindex ImportError: implement sample_db_embedding_widths() in
  embeddings.py. cmd_vec_reindex imported and called it but it was never
  defined, so the command died on import before doing any work. The probe
  reads a sample of vec_memories rows, computes each float32 width, and
  cross-checks against the DDL-declared dim so the destructive DROP+CREATE
  refuses to run on a mixed-width/corrupt index unless --force.

#161 vsearch aborts on missing vec tables: guard _vsearch_table against
  sqlite3.OperationalError for an absent vec table (vec_events/vec_context
  are in the default table set but never created), returning [] for that
  source so vsearch still surfaces results from vec_memories. Implementing
  events/context vector indexing is left as a follow-up.

#168 dream-cycle NREM crash: normalize parse_ts to always return aware UTC
  and coerce a naive 'now' to aware UTC inside days_since, so the Hebbian
  pass no longer mixes offset-naive datetime.now() with aware UTC created_at
  values. A repo-wide naive-vs-aware datetime.now() audit is noted as
  follow-up (the broader-note in #168).

Adds regression tests for all three (13 new tests; full touched-module set
of 60 tests green).

Fixes #160
Fixes #161
Fixes #168

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018eUi7mmueAJFfBssEezPiP
@TSchonleber TSchonleber changed the title docs: repo review + action plan for open PRs and issues Repo review + fixes for 3 broken commands (vec reindex, vsearch, dream-cycle) Aug 6, 2026
… API

An unbounded 'mcp>=1.27.0' now resolves to mcp 2.0.0, which deleted the
decorator-style low-level Server API (@app.list_tools() / @app.call_tool())
that src/agentmemory/mcp_server.py is built on. Every 'import
agentmemory.mcp_server' therefore blows up at import time with
'AttributeError: Server object has no attribute list_tools', taking out 12
test modules at collection and turning the required 'test' and 'docs-check'
CI jobs red on every PR (and on main).

Bound the pin below 2.0.0 in both the 'mcp' and 'all' extras until the
server is migrated to the 2.x API. Verified against a clean venv: with
mcp 1.29.0 the full suite collects and runs 2529 passed (the only failures
are sandbox-only — a HuggingFace 403 in the rerank smoke and a root-user
permission-fallback test — both green on non-root CI with network).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018eUi7mmueAJFfBssEezPiP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment