{"record":{"id":"fabe1a88e95e5f8f","repo":"gastownhall/beads","slug":"reporoot-no-longer-exists-s","errorCode":null,"errorMessage":"RepoRoot no longer exists: %s","messagePattern":"RepoRoot no longer exists: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/beads/context.go","lineNumber":538,"sourceCode":"\treturn &RepoContext{\n\t\tBeadsDir:     beadsDir,\n\t\tRepoRoot:     repoRoot,\n\t\tCWDRepoRoot:  cwdRepoRoot,\n\t\tIsRedirected: false, // Workspace-specific context is never \"redirected\"\n\t\tIsWorktree:   isWorktree,\n\t}, nil\n}\n\n// Validate checks if the cached context is still valid.\n//\n// Returns an error if BeadsDir or RepoRoot no longer exist. This is useful\n// for long-running processes that need to detect when context becomes stale (DMN-002).\nfunc (rc *RepoContext) Validate() error {\n\tif _, err := os.Stat(rc.BeadsDir); os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"BeadsDir no longer exists: %s\", rc.BeadsDir)\n\t}\n\tif _, err := os.Stat(rc.RepoRoot); os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"RepoRoot no longer exists: %s\", rc.RepoRoot)\n\t}\n\treturn nil\n}\n\n// GitOutput runs a git command in the beads repository and returns its output.\n//\n// This is a convenience wrapper around GitCmd that captures stdout.\n// Returns an error if the command fails or produces no output.\n//\n// Pattern:\n//\n//\toutput, err := rc.GitOutput(ctx, \"config\", \"--get\", \"beads.role\")\n//\tif err != nil {\n//\t    // Config key not set or git error\n//\t}\nfunc (rc *RepoContext) GitOutput(ctx context.Context, args ...string) (string, error) {\n\tcmd := rc.GitCmd(ctx, args...)\n\toutput, err := cmd.Output()","sourceCodeStart":520,"sourceCodeEnd":556,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/beads/context.go#L520-L556","documentation":"RepoContext.Validate() re-checks that the cached RepoRoot still exists; if os.Stat reports it missing, this error is returned. Like the BeadsDir check, it lets long-running processes detect that the repository root was deleted or moved after the context was captured (DMN-002). A stale RepoRoot means all git-based operations of the cached context are invalid.","triggerScenarios":"Calling rc.Validate() on a RepoContext whose rc.RepoRoot path no longer exists — the repo was deleted, moved, or its mount disappeared after the context was built.","commonSituations":"Working in a repo checked out in /tmp that was cleaned up; a repo directory renamed while a daemon holds the context; a network checkout that went offline; CI workspaces deleted between steps while a process still caches the context.","solutions":["Re-resolve the context from the new repo location (GetRepoContextForWorkspace at the moved path)","Restore the repository (re-clone or re-mount) at the original path if other tooling depends on it","In long-running processes, treat this error as 'rebuild context' and refresh the cached RepoContext","Check for typos in any configured repo path if the path never existed"],"exampleFix":"// before\nif err := ctx.Validate(); err == nil { use(ctx) }\n// after\nif err := ctx.Validate(); err != nil {\n    ctx, err = beads.GetRepoContextForWorkspace(newRepoPath)\n}\n","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(cached.RepoRoot); os.IsNotExist(err) {\n    cached, err = beads.GetRepoContextForWorkspace(newRepoPath)\n}","typeGuard":null,"tryCatchPattern":"if err := rc.Validate(); err != nil {\n    if strings.Contains(err.Error(), \"RepoRoot no longer exists\") {\n        rc, err = beads.GetRepoContextForWorkspace(locateRepo())\n    }\n}","preventionTips":["Periodically Validate() cached contexts before use","Don't delete or rename the repository while tools hold a RepoContext","Avoid /tmp or other auto-cleaned locations for long-lived repos","After moving a repo, re-resolve context from the new path"],"tags":["beads","stale-context","git","filesystem"],"backgroundTag":"stale-context-path-missing","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}