Notes shorter than 40 characters are silently skipped, so the README "Verify" example indexes 0 notes

Open Beginner friendly
#131 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python, sqlite
Domain
data, search

Research direction

Start with chunks_of() and _chunk_note in src/sqlite_graph_memory/index_notes.py, then read the README "Verify" section and the fake encoder examples in tests/test_index_notes.py or tests/test_incremental_index.py. Check how main reports notes that produce no chunks. Done means the three README notes are indexed, an empty note is counted as skipped, and focused tests cover both cases.

Written by the indexing model from the issue text.

Description

bug documentation good first issue

What happens

chunks_of() drops every chunk shorter than 40 characters (src/sqlite_graph_memory/index_notes.py:66, if len(c) >= 40). A note whose whole body is shorter than that produces no chunk and is left out of the index. sgm-index does not say so.

The README section "Verify" suggests a first test with three notes and gives their text: project-ouzel.md ("Built with [[tool-lanternfish]]"), tool-lanternfish.md ("written in Elixir") and meeting-lighthouse.md ("See [[project-ouzel]]"). They are 31, 17 and 21 characters long. Following it literally on a clone of master (0.3.9, Windows 11, Python 3.12, [lite] backend, fresh index folder):

$ sgm-index ./notes
no indexable .md notes found under notes
$ echo $?
0

The README says to expect indexed 3 chunks from 3 files -> <index folder>. The next two commands of the same section then run against the empty index that this first run wrote: sgm-doctor ends with All good. and sgm-ask --ab ... stops with a traceback. That part is tracked in #130; this issue is about the notes being skipped.

With a mixed folder the skip is invisible. I made the meeting note 91 characters long and kept the other two as above, with a fresh index folder:

$ sgm-index ./notes
  encoded 1/1
indexed 1 chunks from 1 files -> <index folder>

Nothing tells the user that two of three notes were left out. Those two notes can still be link targets, but they can never be returned by recall.

Why it matters

This is the documented first test for a new user or for an agent doing the setup, and it fails at step one with a message that suggests the folder is wrong. In real vaults, short notes are common (a person card with one line, a stub that only links elsewhere), and they vanish from recall without a trace.

Suggested approach

  • Keep the 40-character floor for trailing fragments of a long note, but always emit at least one chunk for a note whose body is non-empty after stripping. For example: in _chunk_note, if chunks_of(body) yields nothing and body.strip() is not empty, use the stripped body as the single chunk.
  • Count notes that produced no chunk (empty body, unreadable) and print it in the summary line, for example indexed 1 chunks from 1 files (2 notes skipped: empty) -> ....
  • If you would rather keep short notes out on purpose, say so in this thread first. Then the minimal fix is: print the skipped count, and change the README example notes so each body is longer than 40 characters.

Done when

  • The three notes from README "Verify", typed exactly as written there, give indexed 3 chunks from 3 files.
  • A new test in tests/test_index_notes.py or tests/test_incremental_index.py (fake encoder, no model) indexes a 17-character note and asserts it has a row in the meta. The test fails on current master.
  • A test asserts that a note with an empty body is reported in the skipped count and does not crash the run.
  • python -m pytest -q shows no new failures.

Where to start

  • src/sqlite_graph_memory/index_notes.py: chunks_of (line 62), _chunk_note (line 126), main (line 257)
  • README.md: section "Verify"
  • tests/test_index_notes.py, tests/test_incremental_index.py (shows how to inject a fake encoder)

New here? Comment that you are taking it and ask anything in this thread; small PRs are reviewed within a day.

Dominant language
Python
Stars
9
Forks
6
Avg merge
13h 8m
Merged PRs (30d)
40

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tonydzi/sqlite-graph-memory

All issues in tonydzi/sqlite-graph-memory

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.