From 04a9a4963c01f8300be6d973894c51f171668996 Mon Sep 17 00:00:00 2001 From: Riz Ashraf Date: Mon, 14 Sep 2026 04:17:33 +0100 Subject: [PATCH] docs: document git2 automated context binding in design and instructions --- design.md | 5 ++++- instructions.md | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/design.md b/design.md index 82d903c..01b0dd4 100644 --- a/design.md +++ b/design.md @@ -152,4 +152,7 @@ To trace binary provenances during rapid deployment cycles, all binaries embed d ## 16. Testing Architecture (Native Rust E2E) Historically, the project relied on a complex Python testing suite (\pytest\ + \mcp_client.py\) to validate the server over HTTP/SSE. This has been fully deprecated in favor of **Native Rust End-to-End Testing**. * **Unit Tests:** Handlers and business logic are tested directly inside \server/src/handlers.rs\ using native \ okio::test\ constructs. -* **E2E Tests:** Integration and full-system tests run via \stub/tests/e2e.rs\ and \win-nvim/tests/integration_test.rs\, ensuring type safety, faster execution, and eliminating Python environment dependencies. \ No newline at end of file +* **E2E Tests:** Integration and full-system tests run via \stub/tests/e2e.rs\ and \win-nvim/tests/integration_test.rs\, ensuring type safety, faster execution, and eliminating Python environment dependencies. +## 17. Automated Git Context Binding (git2) +Instead of forcing the LLM client to manually run `git rev-parse HEAD` and pass `git_branch` / `git_commit` arguments for every single code change, the server integrates the native **`git2`** C bindings. +When engineering endpoints (`log_code_change`, `log_error_fix`, `log_tech_debt`) are invoked, the server asynchronously discovers the surrounding Git repository, peels the HEAD reference, and automatically injects the current commit hash, commit message, and branch name directly into the stored entities and audit logs. This guarantees airtight VCS traceability without wasting LLM tokens or relying on the agent's memory. \ No newline at end of file diff --git a/instructions.md b/instructions.md index 1a8feaf..faa87f7 100644 --- a/instructions.md +++ b/instructions.md @@ -102,8 +102,8 @@ When starting a new session, get a numerical aggregate of the project's current ## Git Context Binding (VCS Sync) To maintain absolute traceability, we link memory items directly to the exact git commits they occurred on. -- When calling **log_code_change**, **log_error_fix**, or **log_tech_debt**, you should execute git rev-parse HEAD and git branch --show-current in the project directory first (if it's a git repo). -- Pass the resulting hash and branch name into the git_commit and git_branch arguments of those tools to permanently link the memory item to the VCS state. +- **Fully Automated (git2):** You no longer need to manually execute `git rev-parse HEAD` or pass `git_branch` / `git_commit` arguments. +- When you call tools like **log_code_change**, **log_error_fix**, or **log_tech_debt**, the Rust server uses the native `git2` crate to automatically discover the repository context of the active working directory, extract the current HEAD commit hash, message, and branch, and permanently bind them to the memory item in the background. ## 13. Server Lifecycle & Updates (Graceful Shutdown) When instructed to restart, update, or stop the mcp-memory-server binary, never use brute-force OS kill commands (e.g. Stop-Process, pkill, kill).