about summary refs log tree commit diff
path: root/main.odin
diff options
context:
space:
mode:
authorPjotr Prins <pjotr.public01@thebird.nl>2026-11-17 10:18:26 +0000
committerPjotr Prins <pjotr.public01@thebird.nl>2026-11-17 10:18:26 +0000
commitb7234d2514b4a693b37cf4968b267a5fafe16678 (patch)
tree0691588a6d1507230f9298ac18b855675c4d2eeb /main.odin
parentb861693dc26a8f9944c3464a34c101af5a81d33c (diff)
downloadai-memory-master.tar.gz
symbols: scan Python and Ruby declarations, and make why FILEBASE resolve HEAD master
A commit that only adds a file recorded nothing: git has no before-side for
the new file, so its hunks carry no context ("@@ -0,0 +1,207 @@"), and Python
and Ruby had no declaration scanner to fall back on. Adding
bin/geno2mdb.py to gemma-wrapper left one commit row and two reasoning
entries with no symbol at all, so `why` could not reach them while `search`
and `list` could.

Both languages are now scanned line by line, which is the right tool here:
in Python and Ruby a declaration is the first token on its line, so the
keyword decides -- `def foo(bar):` declares, `foo(bar)` calls -- the
distinction no C++ line scanner can make.

  Python   def / async def -> fn, class -> type, and at column 0 only
           NAME = value -> const, NAME: Type -> var (an indented assignment
           is a local inside a def)
  Ruby     def / def self.NAME (with ? ! = suffixes) -> fn, class / module ->
           type, and a column-0 capitalised NAME = value -> const

An added file needs no special case: every one of its lines is a '+' line,
which git_touched already walks, so the same path that records an added line
in an existing file now records a new file's declarations. Names strip .py
and .rb like .odin and .rs (script.helper); the C family keeps its extension
because a header declaration and the source definition are different rows.

The lookup's last resort was `s.name like '%name'` -- a suffix match -- so
`why geno2mdb` could never find a file's own symbols even though SKILL.md
documents a LIKE '%...%' scan. It is a substring match now, so the file base
works, and the doc is true again.

The check phase commits script.py and script.rb into its throwaway
repository and asserts both land as `add` rows and that `why script`
resolves; measured on gemma-wrapper, sync adds 344 touches over 319 commits
and `why read_snps` reaches the reasoning attached to the commit that
introduced it.
Diffstat (limited to 'main.odin')
-rw-r--r--main.odin5
1 files changed, 4 insertions, 1 deletions
diff --git a/main.odin b/main.odin
index 0d4c58a..44c2ff1 100644
--- a/main.odin
+++ b/main.odin
@@ -655,8 +655,11 @@ lookup_touches :: proc(db: ^Db, name: string) -> []Touch_Row {
 	if len(by_basename) > 0 {
 		return by_basename
 	}
+	// Substring, not suffix: `why geno2mdb' should reach geno2mdb.main, and the
+	// documented behaviour is a LIKE '%...%' scan.  It was a suffix match
+	// (LIKE '%name'), which could not find a file's own symbols at all.
 	return run_touches(db, fmt.tprintf(TOUCH_QUERY, "s.name like ?1"),
-	                   fmt.tprintf("%%%s", name))
+	                   fmt.tprintf("%%%s%%", name))
 }
 
 run_touches :: proc(db: ^Db, query, name: string) -> []Touch_Row {