{"record":{"id":"8f48aa95d8ac34bd","repo":"JuliusBrussee/caveman","slug":"store-memory-w","errorCode":null,"errorMessage":"store memory: %w","messagePattern":"store memory: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mem/store.go","lineNumber":185,"sourceCode":"\tif strings.TrimSpace(text) == \"\" {\n\t\treturn Memory{}, fmt.Errorf(\"cannot remember empty text\")\n\t}\n\tif err := validateMemorySize(text); err != nil {\n\t\treturn Memory{}, err\n\t}\n\tid := memID(text)\n\tcreated := time.Now().UTC().Format(time.RFC3339Nano)\n\t// INSERT OR IGNORE keeps the original created_at on a repeat remember.\n\t// RetryOnBusy: under a fan-out of cavemem processes, a queued writer can\n\t// outlast a single busy_timeout (Windows file locking is the slowest case).\n\tif err := ccr.RetryOnBusy(func() error {\n\t\t_, e := s.db.Exec(\n\t\t\t`INSERT OR IGNORE INTO memories (id, text, created_at, valid_from) VALUES (?, ?, ?, ?)`,\n\t\t\tid, text, created, created,\n\t\t)\n\t\treturn e\n\t}); err != nil {\n\t\treturn Memory{}, fmt.Errorf(\"store memory: %w\", err)\n\t}\n\tvar stored Memory\n\trow := s.db.QueryRow(memorySelect+` WHERE id = ?`, id)\n\tif err := scanMemory(row, &stored); err != nil {\n\t\treturn Memory{}, fmt.Errorf(\"read back memory: %w\", err)\n\t}\n\tif stored.ValidUntil != nil {\n\t\treturn Memory{}, fmt.Errorf(\"memory %s exists only as an expired historical version and cannot be re-remembered as current\", stored.ID)\n\t}\n\treturn stored, nil\n}\n\n// Supersede atomically replaces one current memory with a new current version.\n// The old row remains durable for history and byte-exact audit, but normal recall\n// excludes it. An already-expired or unknown id fails closed.\nfunc (s *Store) Supersede(oldID, newText string) (Memory, error) {\n\tif strings.TrimSpace(oldID) == \"\" {\n\t\treturn Memory{}, fmt.Errorf(\"supersede requires old memory id\")","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/mem/store.go#L167-L203","documentation":"Error \"store memory: %w\" thrown in JuliusBrussee/caveman.","triggerScenarios":"Thrown at mem/store.go:185 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the memory store write error and retry."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}