From bad6b39ac21043fb45ccb2927fc4087d14f4a56e Mon Sep 17 00:00:00 2001 From: phernandez Date: Mon, 20 Jul 2026 21:48:41 -0500 Subject: [PATCH] fix(core): normalize coding-session paths to POSIX form MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Git emits repo_root with forward slashes on every platform, while the hook event cwd arrives in native form — on Windows that is C:/Users vs C:\Users, so the coding checkpoint's repo_root == cwd identity broke and tests/cli/test_coding_session_context.py failed on the Windows matrix. Main never saw it: the #1125 push run was cancelled by the follow-up merge and the next run skipped the Python matrix (plugins-only change). Store both fields in POSIX form so coding-session path identity is comparable and queryable cross-platform. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01A2bgrGfWiL4izcjj66u9R8 Signed-off-by: phernandez --- src/basic_memory/cli/commands/hook.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/basic_memory/cli/commands/hook.py b/src/basic_memory/cli/commands/hook.py index af2aea00e..5b512ad14 100644 --- a/src/basic_memory/cli/commands/hook.py +++ b/src/basic_memory/cli/commands/hook.py @@ -773,7 +773,9 @@ def _coding_context(cfg: dict, directory: str) -> CodingContext: raise RuntimeError("coding session profile requires basicMemory.repository; rerun bm-setup") return CodingContext( repository=repository.strip(), - repo_root=_required_git_value(directory, "rev-parse", "--show-toplevel"), + # as_posix keeps repo_root in the forward-slash form git already emits on + # every platform, so stored path identity is queryable cross-platform. + repo_root=Path(_required_git_value(directory, "rev-parse", "--show-toplevel")).as_posix(), branch=_required_git_value(directory, "rev-parse", "--abbrev-ref", "HEAD"), git_sha=_required_git_value(directory, "rev-parse", "HEAD"), pull_request=_pull_request_context(directory), @@ -849,6 +851,13 @@ def _checkpoint_note( safe_coding_context: dict[str, str] | None = None if coding_context is not None: + # Trigger: coding sessions require repo_root == cwd to be comparable identity. + # Why: git emits repo_root with forward slashes on every platform, while the + # event cwd arrives in native form — on Windows that's C:\Users vs C:/Users. + # Outcome: store the coding note's cwd in the same POSIX form as repo_root. + # (Redaction ran first; the [redacted-path] sentinel has no separators and + # passes through as_posix unchanged.) + metadata["cwd"] = Path(safe_cwd).as_posix() safe_coding_context = { "repository": redactor.redact_text(coding_context.repository), "repo_root": redactor.redact_text(coding_context.repo_root),