Skip to content

memory: index lock should follow the configured state backend (machine local for orphan/two-layer), not always land in .squad/backend/ #2379

Closed

Description

@tamirdresher

Follow up from the security review of #2356 (memory index lock), non blocking, found by Worf.

Finding (SEC-2, medium): LocalMemoryStore takes its lock at {teamSquadDir}/backend/locks/memory-index on disk regardless of the configured backend (packages/squad-sdk/src/memory/index.ts:657-671). For orphan, git-notes and two-layer backends this contradicts the repo invariant in backend-mcp.ts:146 (a configured backend keeps its locks machine local, nothing lands in .squad/backend/, see state-backend-store.ts:142-186 resolveLockDir / machineLocalLockDir).

Consequences

  • Two linked worktrees or two checkouts sharing one orphan squad-state ref write the same index.json but take different locks, so the lost update race persists for exactly the multi worktree case that motivated shared backends. Not a regression, the old in process mutex never covered it either, but the changeset wording "across local store instances and processes" over claims.
  • .squad/backend/locks/ gets created in every project using memory. Mitigated by the .squad/backend/ gitignore entry added in upgrade, only an empty dir remains, but pre preview.1 repos that never ran squad upgrade will see an untracked directory.

Ask

  • Route the lock through the backend aware resolution (createStateBackendStore(backend, { lockAnchor: squadDir }) style) when storage is not an FSStorageProvider, so configured backends lock machine locally and share the lock across worktrees.
  • Tighten the changeset wording to what is actually covered.

Reference: #2356, #2334.

Activity

  1. added
    squadSquad triage inbox — Lead will assign to a member
    on Nov 1, 2026
  2. github-actions commented on Nov 1, 2026

    @github-actions
    Contributor

    🔄 Ralph — Auto-Triage

    Assigned to: security-reviewer
    Reason: Matched routing keyword(s): Security review, security, review
    Source: routing-rule

    Ralph auto-triaged this issue using routing rules.
    To reassign, swap the squad:* label.

  3. added a commit that references this issue on Nov 4, 2026
    be57a5b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    squadSquad triage inbox — Lead will assign to a membersquad:security-reviewerAssigned to security-reviewer (Security Reviewer)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions