Tag observations with branch and commit_sha at write time and filter SessionStart context and MCP search results to only show observations from commits that are ancestors of the current HEAD. Include graceful degradation for non-git directories, detached HEAD, and shallow clones.
**Type:** feature / enhancement request (re-filed from maintainer's own PR during backlog cleanup) ## Summary - **Branch-scoped observations**: Observations are tagged with `branch` and `commit_sha` at write time via `detectCurrentBranch` in the hook layer - **Git ancestry filtering**: SessionStart context and MCP search results are filtered to only show observations from commits that are ancestors of the current HEAD - **Graceful degradation**: Non-git directories, detached HEAD, shallow clones, and resolution errors all fall back to showing all observations (no data loss) ## Implementation (6 phases) | Phase | What | |-------|------| | 01 | Schema migration (`branch`/`commit_sha` columns), `detectCurrentBranch`, write path through `storeObservation` | | 02 | `resolveVisibleCommitShas` git ancestry utility with `git merge-base --is-ancestor` batching | | 03 | SessionStart `ContextBuilder.generateContext()` filters observations by branch ancestry | | 04 | MCP search `SearchManager.