{"record":{"id":"268fdfac933eaf98","repo":"JuliusBrussee/caveman","slug":"ccr-recovery-handle-not-found","errorCode":null,"errorMessage":"ccr: recovery handle not found","messagePattern":"ccr: recovery handle not found","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/ccr/store.go","lineNumber":29,"sourceCode":"// platforms (store_sqlite.go) and a pure-Go in-memory map under js/wasm\n// (store_wasm.go), since modernc.org/sqlite does not build for js/wasm. Both\n// expose the same type and methods, so the engine is unaware of the difference.\npackage ccr\n\nimport (\n\t\"bytes\"\n\t\"crypto/sha256\"\n\t\"encoding/hex\"\n\t\"errors\"\n\t\"fmt\"\n\t\"slices\"\n\t\"strings\"\n\t\"time\"\n)\n\n// ErrNotFound is returned by Get when a handle is unknown. The store never\n// guesses a recovery — an unknown handle is an explicit miss.\nvar ErrNotFound = errors.New(\"ccr: recovery handle not found\")\n\n// ErrBudgetExceeded means a new recovery was refused before publishing lossy\n// bytes because the local store's configured payload budget would be exceeded.\n// Existing handles remain intact and retrievable; callers must pass through.\nvar ErrBudgetExceeded = errors.New(\"ccr: storage budget exceeded\")\n\n// ErrStorageChanged means the recovery database no longer matches the open\n// connection. Callers must preserve the original input and report the error.\nvar ErrStorageChanged = errors.New(\"ccr: recovery storage changed; restart the process and restore missing recovery files\")\n\n// ObjectType is a closed typed-working-memory enum. Unknown values fail closed:\n// adapters may preserve unknown native payloads outside CCR, but may not invent\n// retrieval semantics for them.\ntype ObjectType string\n\nconst (\n\tObjectFileObservation      ObjectType = \"FileObservation\"\n\tObjectSearchResult         ObjectType = \"SearchResult\"","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/engine/ccr/store.go#L11-L47","documentation":"The CCR (crash-consistent recovery) store's sentinel ErrNotFound. The store never guesses: a handle that is not in the local store is an explicit miss rather than a silent fallback. Returned by get, getMetadata, getObject, setObjectCurrentness, setObjectLifecycle, and findTaskDecision when the SQL query finds no row.","triggerScenarios":"Calling Get/GetMetadata/GetObject/SetObjectCurrentness/SetObjectLifecycle/FindTaskDecision with a handle never stored in this store's database, or one that was deleted/expired; pointing the store at a different or recreated database file.","commonSituations":"Handle from another machine/profile; DB file deleted or moved between runs; handle typo'd or trimmed; store path changed via config so a fresh empty DB is opened.","solutions":["Confirm the handle was created by this store instance (same DB path in config).","Use errors.Is(err, ccr.ErrNotFound) and fall back to re-creating the recovery record.","Check the store's database file path/config — a changed path yields an empty store.","Restore the missing recovery database from backup if handles are long-lived."],"exampleFix":"// before\nrec, err := store.Get(handle)\nif err != nil { return err }\n\n// after\nrec, err := store.Get(handle)\nif errors.Is(err, ccr.ErrNotFound) {\n    return recomputeRecovery(input) // regenerate, don't guess\n}\nif err != nil { return err }","handlingStrategy":"fallback","validationCode":"if handle == \"\" { return errors.New(\"handle required before Get\") }","typeGuard":null,"tryCatchPattern":"rec, err := store.Get(handle)\nswitch {\ncase errors.Is(err, ccr.ErrNotFound):\n    return regenerateRecovery(input) // explicit miss: re-create\ncase err != nil:\n    return fmt.Errorf(\"ccr get: %w\", err)\n}\nreturn nil","preventionTips":["Always branch on errors.Is(err, ccr.ErrNotFound) instead of string matching.","Keep the store DB path stable in configuration across runs.","Back up the recovery database if handles are long-lived.","Never construct handle strings manually; use returned values."],"tags":["ccr","not-found","recovery-handle","sentinel-error"],"backgroundTag":"record-not-found","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}