Skip to content

[upstream PR 929] f<!-- -->ix: scope git worktrees to shared project id #383

@wbugitlab1

Description

@wbugitlab1

Source: Source pull request number: 929 in rohitg00/agentmemory (URL omitted to avoid GitHub cross-reference)
Title: fix: scope git worktrees to shared project id
Author: wbugitlab1
State: closed
Draft: no
Merged: no
Head: wbugitlab1/agentmemory:fix/worktree-project-scope @ c234cbd
Base: main @ f6f9e3c
Labels: (none)
Changed files: 0
Commits: 0
Created: 2026-06-14T02:51:35Z
Updated: 2026-06-14T15:27:17Z
Closed: 2026-06-14T15:27:17Z
Merged at: (not merged)

Original PR body:

Summary

  • resolve project scope through a canonical git project id instead of raw cwd path
  • make linked worktrees for the same repository share the same git:<hash> project scope
  • preserve explicit AGENTMEMORY_PROJECT_ID / AGENTMEMORY_PROJECT_NAME overrides and non-git basename fallback
  • expose optional project arguments through MCP/REST memory operations

Verification

  • npm run build passed
  • npm run skills:check passed
  • npx vitest run test/worktree-project-scope.test.ts test/hook-project.test.ts test/api-memories-project.test.ts test/mcp-project-scope.test.ts test/pre-tool-use-project.test.ts test/remember-project-scope.test.ts test/mcp-standalone.test.ts test/mcp-standalone-proxy.test.ts passed: 8 files, 72 tests
  • gitleaks protect --staged --redact passed
  • gitleaks detect --source . --log-opts 'origin/main..HEAD' --redact passed
  • git diff --name-only origin/main..HEAD | xargs semgrep scan --config p/default --error --metrics=off passed: 30 files, 0 findings
  • git diff --check origin/main..HEAD passed

Notes

  • Full npm test currently has unrelated local failures in test/fs-watcher.test.ts; this file is not touched by this PR. Other first-run timeout failures passed when rerun in isolation.
  • Full repo semgrep scan --config p/default --error --metrics=off . reports existing findings outside this PR diff.
  • Full history gitleaks detect --source . --redact reports one historical finding; the PR commit itself is clean.

Manual smoke

A local build of this change was tested with two linked worktrees for the same repo. Hook-generated sessions from both worktrees resolved to the same project id:

/Users/A1538552/_projects/_tools/agentmemory              -> git:c578c496c2ba2535ab6a51797c014666
/Users/A1538552/.codex/worktrees/aba6/agentmemory         -> git:c578c496c2ba2535ab6a51797c014666

Summary by CodeRabbit

Release Notes

  • New Features

    • Memories can be scoped to projects via AGENTMEMORY_PROJECT_ID (preferred) or AGENTMEMORY_PROJECT_NAME.
    • Added optional project parameter to memory_recall and smart search tools.
    • The memories API now supports project filtering with includeUnscoped.
  • Improvements

    • Project scoping is now more consistent across Git worktrees; cwd is normalized in event payloads.
    • Project info is no longer exposed in “Memory saved” logging.
  • Documentation

    • Updated environment and tool references to include AGENTMEMORY_PROJECT_ID and the new project parameter.
  • Tests

    • Added/expanded coverage for project scoping, filtering, and worktree behavior.

Local branch:
Fork PR:
Fork decision:
Verification:
Notes:

Metadata

Metadata

Assignees

No one assigned

    Labels

    decision-candidateFork decision has not been madeupstream-closedUpstream pull request is closed unmergedupstream-prTracks an upstream pull request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions