{"record":{"id":"9242496aec7a5f65","repo":"JuliusBrussee/caveman","slug":"record-applied-fix-w","errorCode":null,"errorMessage":"record applied fix: %w","messagePattern":"record applied fix: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/internal/store/learn_outcomes.go","lineNumber":110,"sourceCode":"\tif err != nil {\n\t\treturn AppliedFixRecord{}, fmt.Errorf(\"encode before evidence: %w\", err)\n\t}\n\t// Fingerprint the edited artifact as it stands NOW — which at\n\t// `caveman learn applied` time is immediately after the approved edit. This\n\t// is the provenance anchor: a later scan re-hashes the same path and can\n\t// state whether the change we proposed is still the change that is there.\n\ttarget := fingerprintFixTarget(*sink)\n\ttargetJSON := \"\"\n\tif target != nil {\n\t\tif encoded, encodeErr := json.Marshal(target); encodeErr == nil {\n\t\t\ttargetJSON = string(encoded)\n\t\t}\n\t}\n\tresult, err := s.db.Exec(`INSERT INTO applied_fixes\n\t\t(sink_id, practice_id, fix_kind, applied_at, before_tokens_per_turn, before_evidence_json, note, target_json)\n\t\tVALUES (?, ?, ?, ?, ?, ?, ?, ?)`, sink.SinkID, sink.PracticeID, fixKind, appliedAt, sink.TokensPerTurn, string(evidence), note, targetJSON)\n\tif err != nil {\n\t\treturn AppliedFixRecord{}, fmt.Errorf(\"record applied fix: %w\", err)\n\t}\n\tid, err := result.LastInsertId()\n\tif err != nil {\n\t\treturn AppliedFixRecord{}, fmt.Errorf(\"read applied fix id: %w\", err)\n\t}\n\treturn AppliedFixRecord{\n\t\tRecorded: true, ID: id, SinkID: sink.SinkID, PracticeID: sink.PracticeID,\n\t\tFixKind: fixKind, AppliedAt: appliedAt, BeforeTokensPerTurn: sink.TokensPerTurn,\n\t\tBeforeEvidence: beforeEvidence, BeforeSource: beforeSource, Note: note,\n\t\tTarget: target,\n\t}, nil\n}\n\nfunc beforeSinkForAppliedFix(plan LearnPlan, sinkID string, live *Sink, fallbackCutoff time.Time) (*Sink, string) {\n\tcutoff := fallbackCutoff\n\tif parsed, err := time.Parse(time.RFC3339Nano, plan.computedAt); err == nil {\n\t\tcutoff = parsed\n\t}","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/81536f57b3303b7de7f5bc5b564cc344f9112d68/proxy/internal/store/learn_outcomes.go#L92-L128","documentation":"The INSERT of the applied-fix record into the database failed after validation and JSON encoding succeeded. Database-level failure: locked/corrupt DB, disk error, or schema mismatch in the applied-fix table.","triggerScenarios":"Thrown at proxy/internal/store/learn_outcomes.go:110 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the SQLite database is writable and not locked by another process","Inspect the wrapped driver error for the root cause","Verify the applied-fix table schema matches the INSERT","Re-run the learn applied command once the database is available"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"81536f57b3303b7de7f5bc5b564cc344f9112d68","analyzedAt":"2026-08-27T02:25:50.681Z","contentChangedAt":"2026-08-27T02:25:50.681Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}