{"record":{"id":"a627d46faabcd4b2","repo":"JuliusBrussee/caveman","slug":"ccr-typed-object-budget-w","errorCode":null,"errorMessage":"ccr typed object budget: %w","messagePattern":"ccr typed object budget: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/ccr/store_sqlite.go","lineNumber":503,"sourceCode":"\t}\n\treturn metadata, nil\n}\n\n// PutObject stores one immutable typed working-memory object. Repeated puts of\n// the same content-derived ID are idempotent; currentness changes use\n// SetObjectCurrentness so invalidation stays explicit.\nfunc (s *Store) PutObject(input Object) (string, error) {\n\tobj, err := prepareObject(input)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdeps, err := json.Marshal(obj.Dependencies)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"ccr typed object dependencies: %w\", err)\n\t}\n\tused, err := s.storageBytes()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"ccr typed object budget: %w\", err)\n\t}\n\tvar existingBytes int64\n\terr = s.db.QueryRow(`SELECT length(data)+length(dependencies_json) FROM typed_objects WHERE object_id=?`, obj.ID).Scan(&existingBytes)\n\tif errors.Is(err, sql.ErrNoRows) {\n\t\texistingBytes = 0\n\t} else if err != nil {\n\t\treturn \"\", fmt.Errorf(\"ccr typed object budget: %w\", err)\n\t}\n\tif used-existingBytes+int64(len(obj.Data)+len(deps)) > s.maxBytes {\n\t\treturn \"\", fmt.Errorf(\"ccr typed object put: %w\", ErrBudgetExceeded)\n\t}\n\tresult, err := s.db.Exec(\n\t\t`INSERT INTO typed_objects (\n\t\t object_id, object_type, content_hash, source, created_at, repository_state,\n\t\t session_id, transform_version, currentness, lifecycle, dependencies_json,\n\t\t original_byte_length, stored_byte_length, data\n\t\t) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)\n\t\tON CONFLICT(object_id) DO NOTHING`,","sourceCodeStart":485,"sourceCodeEnd":521,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/engine/ccr/store_sqlite.go#L485-L521","documentation":"Wraps the storageBytes() query failure in PutObject: current retained bytes could not be read, so the budget check for the incoming object cannot be computed. The typed-object put fails closed rather than storing unaccounted bytes.","triggerScenarios":"Thrown at engine/ccr/store_sqlite.go:503 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the wrapped error for lock or corruption causes","Retry the put once the database is quiet","Verify the storage accounting tables are intact"],"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-23T08:17:48.524Z"}