{"record":{"id":"d680dccf02568764","repo":"JuliusBrussee/caveman","slug":"count-memories-w","errorCode":null,"errorMessage":"count memories: %w","messagePattern":"count memories: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mem/store.go","lineNumber":377,"sourceCode":"\tif err := tx.Commit(); err != nil {\n\t\treturn false, fmt.Errorf(\"forget commit: %w\", err)\n\t}\n\treturn true, nil\n}\n\nfunc nullableLineageID(value sql.NullString) any {\n\tif value.Valid {\n\t\treturn value.String\n\t}\n\treturn nil\n}\n\n// Count returns the number of durable memory blocks without loading their\n// contents. Callers omit this number on error rather than presenting zero.\nfunc (s *Store) Count() (int, error) {\n\tvar count int\n\tif err := s.db.QueryRow(`SELECT COUNT(*) FROM memories WHERE valid_until IS NULL`).Scan(&count); err != nil {\n\t\treturn 0, fmt.Errorf(\"count memories: %w\", err)\n\t}\n\treturn count, nil\n}\n\n// Hit is one recall result: the recalled memory compressed for injection, with\n// the inferred token cost, the match score, and a CCR handle to recover the full\n// original when the compression dropped detail.\ntype Hit struct {\n\tID             string  `json:\"id\"`\n\tText           string  `json:\"text\"`\n\tScore          float64 `json:\"score\"`\n\tTokensAdded    int     `json:\"tokens_added\"`\n\tBasis          string  `json:\"basis\"`\n\tRecoveryHandle string  `json:\"recovery_handle,omitempty\"`\n}\n\n// RecallOptions configures Recall. A zero Threshold means DefaultThreshold; a\n// zero Limit means DefaultLimit; a zero TokenBudget means DefaultTokenBudget.","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/mem/store.go#L359-L395","documentation":"Store.Count's COUNT(*) over current memories (valid_until IS NULL) failed at the query level. The wrapped error is the SQLite failure; per the API contract the count is omitted rather than reported as zero.","triggerScenarios":"Thrown at mem/store.go:377 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the count","Check mem.db health/locks","Inspect the wrapped scan error"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"766dce6b1394ebb56a3090748d5a0240a5aefb36","analyzedAt":"2026-08-18T03:14:35.516Z","contentChangedAt":"2026-08-18T03:14:35.516Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}