{"record":{"id":"1c1ffa5f93472ccc","repo":"multica-ai/multica","slug":"close-temp-workspaces-root-marker-w","errorCode":null,"errorMessage":"close temp workspaces root marker: %w","messagePattern":"close temp workspaces root marker: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/internal/daemon/execenv/context.go","lineNumber":107,"sourceCode":"// file plus a rename, so a concurrent reader observes either the old file or the\n// complete new one — never a partial write. Mirrors the daemon-id / CLI-config\n// write idiom (see writeDaemonIDFile). Perm is 0644 because the CLI's upward\n// walk must be able to read the marker from a subprocess that may run under a\n// different uid; the payload is non-secret.\nfunc writeWorkspacesRootMarkerAtomic(path string, data []byte) error {\n\ttmp, err := os.CreateTemp(filepath.Dir(path), \".daemon_task_context-*.json.tmp\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"create temp workspaces root marker: %w\", err)\n\t}\n\ttmpPath := tmp.Name()\n\tif _, err := tmp.Write(data); err != nil {\n\t\ttmp.Close()\n\t\tos.Remove(tmpPath)\n\t\treturn fmt.Errorf(\"write temp workspaces root marker: %w\", err)\n\t}\n\tif err := tmp.Close(); err != nil {\n\t\tos.Remove(tmpPath)\n\t\treturn fmt.Errorf(\"close temp workspaces root marker: %w\", err)\n\t}\n\tif err := os.Chmod(tmpPath, 0o644); err != nil {\n\t\tos.Remove(tmpPath)\n\t\treturn fmt.Errorf(\"chmod temp workspaces root marker: %w\", err)\n\t}\n\tif err := os.Rename(tmpPath, path); err != nil {\n\t\tos.Remove(tmpPath)\n\t\treturn fmt.Errorf(\"rename workspaces root marker: %w\", err)\n\t}\n\treturn nil\n}\n\n// writeContextFiles renders and writes .agent_context/issue_context.md and\n// skills into the appropriate provider-native location.\n//\n// Claude:      skills → {workDir}/.claude/skills/{name}/SKILL.md  (native discovery)\n// CodeBuddy:   skills → {workDir}/.codebuddy/skills/{name}/SKILL.md  (native discovery — CodeBuddy is a Claude Code fork but uses its own config directory, not .claude/; see https://www.codebuddy.ai/docs/cli/skills)\n// Codex:       skills → handled separately in Prepare via codex-home","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/internal/daemon/execenv/context.go#L89-L125","documentation":"Wraps the tmp.Close failure in writeWorkspacesRootMarkerAtomic after the data was written to the temp file. An unclosed file may hold unflushed data, so the temp file is removed and the marker is not renamed into place.","triggerScenarios":"Thrown at server/internal/daemon/execenv/context.go:107 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the temp marker file handle; retry."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}