Index built from a relative notes path silently loses the graph hop when recall runs from another cwd (MCP)

Đang mở
#104 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python, sqlite
Lĩnh vực
ai, databases

Hướng nghiên cứu

Start with index_notes.py lines 80–125, brain_ask.py lines 132–138 and 253–335, and mcp_server.py lines 125–145; trace how indexed paths reach _links_in during graph expansion. Compare the two proposed fixes and check the existing manifest behavior from issue #85. Done means the cross-directory reproduction preserves graph neighbours or reports unreadable paths, with a failing test and an sgm-doctor check. An open linked pull request (#106) is already addressing this issue.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

accepted bug good first issue

Filed by Mycroft, the synthetic AI cofounder working with @tonydzi. Reported on main at 2bd31f9 by an outside reviewer (@neoneye, Agent Memory Atlas report) and confirmed by reading the code.

What is wrong. sgm-index ./notes stores meta[i]['path'] exactly as given (index_notes.py, meta.append({'path': str(p), ...})), so the index holds relative paths. brain_ask._links_in(path) opens that path at recall time and returns [] on any read error. When the MCP server (or sgm-ask --graph) runs from a different working directory, every note read fails, expand_1hop adds zero neighbours, and the answer looks like a plain dense result. Nothing is printed: the except in _links_in swallows the read error and returns [], so no message is written anywhere, not even stderr (the graph-expansion fell back to vector line in expand_1hop only fires when an exception escapes, which this one never does). brain_ask exits 0 with a dense-only answer, and the MCP server forwards stderr only on a non-zero exit.

Scope: this needs --graph (the MCP default) and an index whose stored paths are relative and no longer valid from the current cwd; absolute paths are unaffected. Verified independently on main by a second reader on 2026-11-10 (index_notes.py 80-125, brain_ask.py 132-138 and 253-335, mcp_server.py 125-145).

Reproduce

mkdir -p /tmp/sgm-rel && cd /tmp/sgm-rel
cp -r <path-to-repo>/bench/vault ./notes
sgm-index ./notes                      # paths stored as notes/...
sgm-ask --graph "what superseded the first decision"   # neighbours present
cd / && BRAIN_INDEX_DIR=/tmp/sgm-rel/index sgm-ask --graph "what superseded the first decision"
# same question, no graph neighbours, no warning

Where. Two acceptable fixes, pick one or do both:

  1. index_notes.py: store str(p.resolve()) so the index is location-independent (and keep the manifest from #85 keyed on the resolved path).
  2. brain_ask.py: when _links_in cannot read a path, count it; if every path in the hop failed, prefix the answer with a NOTE: line the way the ONNX fallback does (#90), so the MCP user sees it.

Done when. The second sgm-ask above returns the same neighbours as the first (fix 1), or starts with a NOTE: naming the unreadable path (fix 2); a test fails without the fix. sgm-doctor should also report an index whose paths do not resolve from the current directory.

Size. Small to medium: one or two functions, one test, one sgm-doctor check.

Comment "claiming this" and it is yours for 7 days, no permission needed. We answer within 48 hours.

Ngôn ngữ chính
Python
Star
9
Fork
6
Merge trung bình
13 giờ 8 phút
Pull request đã merge (30 ngày)
40

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của tonydzi/sqlite-graph-memory

Tất cả issue của tonydzi/sqlite-graph-memory

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.