about summary refs log tree commit diff
path: root/git.odin
AgeCommit message (Collapse)Author
16 hourssymbols: scan Python and Ruby declarations, and make why FILEBASE resolve HEAD masterPjotr Prins
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.
33 hoursguix: compile the ctags path in, so $AI_MEMORY_CTAGS still overridesPjotr Prins
wrap-program exports unconditionally, so `export AI_MEMORY_CTAGS=...` in the wrapper overwrote any value the user set: an installed ai-memory always used the store's ctags, and the documented override did nothing. Found by testing the degradation path -- `AI_MEMORY_CTAGS=/nonexistent/ctags` still produced `add` rows, which is only possible if the override was ignored. The default is now CTAGS_DEFAULT, a #config constant that guix.scm fills with -define:CTAGS_PATH=...; $AI_MEMORY_CTAGS is consulted first, and a plain `odin build` leaves the literal `ctags` for PATH. The check phase builds with the same define, so it tests what users get.
34 hourssymbols: C and C++ declarations from ctags, diffed between blobsPjotr Prins
C and C++ were the one language family where the store could only say "a hunk landed inside this function". A diff line cannot be read for declarations there: inside a body `foo(bar);` calls something, inside a class body the same bytes declare a constructor, and pangemma indents both the same way (of 248538 changed lines in its history, 14991 are indented `name(` lines, and the most frequent are calls). So the file is handed to universal-ctags and the tags of a commit's blob are diffed against its parent's: present only in the new blob is an add, only in the old one is a remove, and a name whose tag survives both is left to hunk context, which is the honest answer for "the change was inside this". The cost is bounded by a cache keyed by git object id (new table `blobs`): a blob's tags can never change, so each file version is parsed once per store. On the pangemma history (688 commits, 1163 distinct C/C++ blobs) the first full pass takes 26 s and touches go from 1404 context-only rows to 6888 add, 5125 remove, 1505 context; the second pass takes 11 s and runs no ctags at all. ctags is optional at run time. Without it the store behaves exactly as before and `sync` says so once. The Guix package bakes its absolute path into $AI_MEMORY_CTAGS through wrap-program, and the check phase now builds a two-commit git repository with one C++ file to prove it end to end: the function added in the second commit is `add`, the one whose body changed is `context`. Details found by running it on a real history, all in this commit: - lambdas are tagged by default under names ctags derives from a hash of the file (`__anon426fc91f0102`), so every touched file reported seven functions added and seven removed per commit; `--extras=-{anonymous}` turns them off. - `--kinds-C++=+p` is needed or prototypes are invisible and a declaration in a header would never be seen. - include guards (`#define CALC_H`, `#define __CALC_H__`) are filtered: they are bookkeeping, while other macros are kept as `const`. - merge_decl keyed a commit's declarations by bare identifier, so two files declaring the same name in one commit collided and one lost its attribution. It is keyed by (file, name) now -- a bug that applied to Odin and Rust too.
6 daysinitial ai-memory: derive commits and symbols from git, author the whyPjotr Prins
commits, symbols and touches are derived from `git log`/`git show` by `sync`; only reasoning is authored, and it is append-only. Each entry records a basis (how it was established) and may supersede an earlier entry instead of rewriting it. Symbols come from two signals: declarations added or removed on diff lines (Odin and Rust), and the enclosing item named in git's own hunk headers, which needs no parser and works for any language with a userdiff driver. Links SQLite through the odin-sqlite3 bindings; guix.scm builds both the compiler and the tool. doc/SKILL.md is the operating guide.