Skip to content

Add atomic repository-scoped create-if-absent state operation #1947

Closed

Description

@cyrusjamula

Problem

Squad state MCP exposes unconditional writes but no atomic key creation. Workflows requiring one canonical artifact can race, allowing one creator to overwrite another.

Required behavior

Add a create-if-absent operation that:

  • Atomically creates a repository-scoped state key only when absent.
  • Supports local, orphan, notes, and two-layer backends.
  • Returns success to exactly one concurrent creator and a typed conflict to all others.
  • Fails closed when existence, repository identity, or backend outcome is uncertain.
  • Never overwrites existing content.
  • Preserves current unconditional write behavior for backward compatibility.
  • Is exposed through StorageProvider, ToolRegistry, and state-mcp.

Internal Git-ref CAS is insufficient by itself: it protects ref advancement, not conditional creation of a repository state key.

Tests

For every backend, run two concurrent creators against the same absent key and prove:

  • Exactly one succeeds.
  • Exactly one reports conflict.
  • The winning content is preserved.
  • No partial or duplicate state remains.

Also test existing keys, repository isolation, backend uncertainty, and two-layer disagreement or failure.

Documentation and release

Document semantics, conflict and error contracts, repository scoping, backend guarantees, MCP tool registration, migration guidance, and the first released CLI version containing the operation.

Related context: issue #1211 and commit 8f7e7f7 added ref CAS; PR #1200 connected backends to MCP; proposal #1829 states atomic read-modify-write still needs implementation.

Andreja integration acceptance

After release:

  1. Update the exact @bradygaster/squad-cli version pin from 0.12.0.
  2. Add the create-if-absent tool to the allowlist.
  3. Restart the MCP server.
  4. Verify the operation appears in tools/list.
  5. Verify exclusive Scribe can atomically create the canonical retrospective.

Activity

  1. added 5 commits that reference this issue on Oct 8, 2026
    8f29358
    de66746
    a54fff7
    b03c443
    472d56e
  2. added 2 commits that reference this issue on Oct 8, 2026
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions