Skip to main content

Module workspace_root

Module workspace_root 

Source
Expand description

Workspace-root utilities. Today’s only consumer is the memstead_health OUTER_REPO_NOT_IGNORING_MEM_REPO warning surfaced by the MCP layer: when the workspace is embedded inside another git repository, the mem-repo-git directory must be excluded by the outer repo’s .gitignore to avoid the gitlink trap.

Pure path-walking — no IO beyond metadata / read_to_string for the gitignore probe — so this module is safe to call from any engine surface, including read-only health queries.

Functions§

find_enclosing_git_repo
Walk parent directories from workspace_root.parent() upward looking for a .git directory or file. Returns the first ancestor that carries one, or None when none exist (for example, the workspace is not embedded inside another git repository).
outer_repo_ignores_mem_repo
Returns true when the outer repo at outer_repo_root contains a .gitignore line that ignores mem-repo/ (with or without a leading workspace-relative prefix). The match is whitespace- and trailing-slash-insensitive: mem-repo, mem-repo/, memstead/mem-repo, and memstead/mem-repo/ all count as “ignored.” A negation (!mem-repo/) cancels the match.