{"record":{"id":"58fce7249d497adf","repo":"JuliusBrussee/caveman","slug":"native-runtime-store-is-required","errorCode":null,"errorMessage":"native runtime: store is required","messagePattern":"native runtime: store is required","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/internal/nativeruntime/server_unix.go","lineNumber":34,"sourceCode":"// choose this path, preventing one integration from impersonating another\n// user's runtime.\nfunc SocketPath(home string) string { return filepath.Join(home, \"run\", \"native.sock\") }\n\nfunc dialNativeRuntime(ctx context.Context, home string) (net.Conn, error) {\n\treturn (&net.Dialer{}).DialContext(ctx, \"unix\", SocketPath(home))\n}\n\n// Serve binds runtime transport for current platform.\nfunc Serve(ctx context.Context, home string, runtime *Runtime) error {\n\treturn ServeUnix(ctx, SocketPath(home), runtime)\n}\n\n// ServeUnix exposes one-request-per-connection JSON over a user-only Unix\n// socket. Runtime errors close or fail-open the individual call; they never stop\n// the coding agent or the provider proxy.\nfunc ServeUnix(ctx context.Context, path string, runtime *Runtime) error {\n\tif runtime == nil || runtime.store == nil {\n\t\treturn errors.New(\"native runtime: store is required\")\n\t}\n\tif err := os.MkdirAll(filepath.Dir(path), 0o700); err != nil {\n\t\treturn fmt.Errorf(\"native runtime mkdir: %w\", err)\n\t}\n\tif err := os.Chmod(filepath.Dir(path), 0o700); err != nil {\n\t\treturn fmt.Errorf(\"native runtime chmod dir: %w\", err)\n\t}\n\tif _, err := os.Stat(path); err == nil {\n\t\tconn, dialErr := net.DialTimeout(\"unix\", path, 50*time.Millisecond)\n\t\tif dialErr == nil {\n\t\t\t_ = conn.Close()\n\t\t\treturn errors.New(\"native runtime: socket already active\")\n\t\t}\n\t\tif err := os.Remove(path); err != nil {\n\t\t\treturn fmt.Errorf(\"native runtime remove stale socket: %w\", err)\n\t\t}\n\t} else if !os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"native runtime inspect socket: %w\", err)","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/proxy/internal/nativeruntime/server_unix.go#L16-L52","documentation":"ServeUnix requires a Runtime carrying a non-nil ccr store before it will create the Unix socket. Because each socket call can only serve decisions from the store, a store-less runtime is a configuration error detected up front.","triggerScenarios":"ServeUnix(ctx, path, runtime) called with runtime == nil or runtime == &Runtime{} without a store set (e.g. constructing Runtime manually in tests or wiring the server before store initialization succeeded).","commonSituations":"Store failed to open earlier but startup continued; hand-assembling Runtime in tests/benchmarks; wiring order bug where Serve starts before NewRuntime returns a store-backed runtime.","solutions":["Construct the Runtime via its constructor with an opened *ccr.Store before calling ServeUnix.","Check the store-open error at startup and abort serving instead of continuing with a nil store.","Guard the caller: if runtime == nil || runtime.store == nil, skip serving the native runtime and log.","Serve() (the public entry) may wrap ServeUnix — ensure the store is attached before invoking it too."],"exampleFix":"// before\nrt := &nativeruntime.Runtime{}\ngo nativeruntime.ServeUnix(ctx, sockPath, rt)\n// after\nrt, err := nativeruntime.NewRuntime(store)\nif err != nil { return err }\ngo nativeruntime.ServeUnix(ctx, sockPath, rt)","handlingStrategy":"validation","validationCode":"if rt == nil || rt.Store == nil {\n    return errors.New(\"native runtime requires an initialized store\")\n}","typeGuard":"func servable(rt *nativeruntime.Runtime) bool { return rt != nil && rt.Store != nil }","tryCatchPattern":"if err := nativeruntime.ServeUnix(ctx, path, rt); err != nil {\n    if strings.Contains(err.Error(), \"store is required\") {\n        log.Error(\"native runtime disabled: ccr store not initialized\")\n        return nil\n    }\n    return err\n}","preventionTips":["Use the Runtime constructor instead of struct literals","Abort startup when the ccr store fails to open","Wire Serve only after successful store initialization"],"tags":["configuration","native-runtime","unix-socket"],"backgroundTag":"missing-required-argument","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"}