diff options
| author | Pjotr <wrk@bosa.lan> | 2026-11-16 00:35:30 +0000 |
|---|---|---|
| committer | Pjotr <wrk@bosa.lan> | 2026-11-16 00:35:30 +0000 |
| commit | 692456b495bb531d604670cf2122a8fec1603d24 (patch) | |
| tree | 949da8ace2fd0a6d43b2d48615688742c525ba0c /schema.sql | |
| parent | db19435f20857ee39fd5ef97d954a2de1cebe391 (diff) | |
| download | ai-memory-692456b495bb531d604670cf2122a8fec1603d24.tar.gz | |
record/attach: resolve the commit ref before SQL, and write nothing on failure
`ai-memory record --commit 1ae2f5d` (a short hash) answered
imported 1ae2f5d (qtl2: permutations for the LOD thresholds)
ai-memory: sql error (Error): SQL logic error
and left the store half-updated: the commit row was imported under its full
hash, the reasoning row was not written at all, and the message named neither
the cause nor the fix. Feed the same command the full forty characters and it
worked, which is the sort of difference that reads as flakiness.
Three changes, in the order they matter:
* resolve the ref first. record's --commit and attach's positional argument
both go through resolve_commit_ref, which asks git (`rev-parse --verify`) and
keeps the full hash; if git does not know the ref the command refuses before
opening a transaction, says which ref and which repository, and suggests
--commit none plus a later attach. The store keys commits by the full hash,
so a short ref written to reasoning.commit_hash names a row that cannot exist.
* one transaction around the import and the insert (begin immediate ... commit,
rollback on any failure), so a failed record leaves a store that looks exactly
as it did. Verified against a store whose schema predates the binary: no new
commit row survives the failure.
* an actionable message: an empty sqlite3 errmsg on SQLITE_ERROR now says the
store's schema is older than the binary and to run init, instead of "sql
error (Error):" with nothing after it.
Measured, fresh store: --commit 1ae2f5d records against
1ae2f5d712e18c016fdb7bd04da99eab4da6915b; --commit deadbeef refuses and writes
nothing; --commit HEAD~1 resolves; attach 1ae2f5d links an unattached entry.
Diffstat (limited to 'schema.sql')
0 files changed, 0 insertions, 0 deletions
