Skip to content

docs: add user-facing documentation for state backends#996

Merged
bradygaster merged 2 commits into
devfrom
docs/state-backends-995
Apr 17, 2026
Merged

docs: add user-facing documentation for state backends#996
bradygaster merged 2 commits into
devfrom
docs/state-backends-995

Conversation

@tamirdresher

Copy link
Copy Markdown
Collaborator

Adds comprehensive docs for the git-notes, orphan-branch, and worktree state backends.

What's included

  • Configuration: CLI flag, config.json, priority order, fallback behavior
  • Backend comparison: Worktree vs Git Notes vs Orphan Branch (pros/cons table)
  • Inspecting state: Commands for each backend
  • SDK usage: resolveStateBackend() API and StateBackend interface
  • Security: Hardening details (path traversal, null byte, newline injection)
  • Sharing: How to push/fetch git-notes across clones

Follows the existing Astro Starlight doc pattern (see external-state.md, storage-provider.md).

Closes #995

Adds comprehensive docs for the git-notes, orphan-branch, and worktree
state backends covering configuration, usage, comparison, SDK API,
security hardening, and inspection commands.

Closes #995

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 17, 2026 17:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new user-facing Starlight docs page describing Squad’s Git-native state backends (worktree, git-notes, orphan-branch), including configuration, inspection commands, SDK usage, and security hardening notes.

Changes:

  • Introduces state-backends.md feature documentation covering backend behavior, tradeoffs, and configuration priority/fallback.
  • Documents inspection/sharing commands for git-notes and orphan-branch backends plus the resolveStateBackend() / StateBackend SDK API.
  • Adds a changeset marking this documentation update as a @bradygaster/squad-cli patch.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
docs/src/content/docs/features/state-backends.md New comprehensive documentation page for state backends, configuration, inspection, SDK API, and security notes.
.changeset/docs-state-backends.md Changeset to publish the docs update as a patch release for @bradygaster/squad-cli.

Comment on lines +137 to +145
### CLI Flag (per-invocation)

Pass `--state-backend` to any squad command:

```bash
squad watch --state-backend git-notes
squad watch --state-backend orphan
squad watch --state-backend worktree
```

Copilot AI Apr 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--state-backend is documented here as working with “any squad command”, but the CLI currently only parses/accepts this flag for the watch/triage command path. Please narrow the wording (or list the supported commands) so readers don’t try it with other subcommands and get unexpected behavior.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied in ab256ef.

| Appears in PRs | Yes (if committed) | No | No |
| Human-readable on disk | ✅ Files | ❌ JSON blob | ⚠️ Via `git show` |
| Git history | Via normal commits | Per-note | Per-branch commits |
| Branch-switch safe | ❌ (if uncommitted) | ✅ | ✅ |

Copilot AI Apr 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The “Branch-switch safe” row marks Git Notes as ✅, but earlier the Git Notes section notes state is per-commit and switching commits loses note context. Consider changing this cell to ⚠️ (or clarifying the definition of “branch-switch safe”) so the comparison table doesn’t contradict the behavior described above.

Suggested change
| Branch-switch safe | ❌ (if uncommitted) | ||
| Branch-switch safe | ❌ (if uncommitted) | ⚠️ ||

Copilot uses AI. Check for mistakes.

- State backends are **opt-in** — the default is `worktree` (no behavior change)
- All backends implement the same interface — agents don't know or care which backend is active
- The `external` backend type exists as a stub for future external storage (see [External State](./external-state))

Copilot AI Apr 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relative links in docs/src/content/docs/features/ typically include the .md suffix (e.g., ./routing.md). For consistency (and to avoid any build/link-checker surprises), consider changing [External State](./external-state) to [External State](./external-state.md).

Suggested change
- The `external` backend type exists as a stub for future external storage (see [External State](./external-state))
- The `external` backend type exists as a stub for future external storage (see [External State](./external-state.md))

Copilot uses AI. Check for mistakes.
@bradygaster

Copy link
Copy Markdown
Owner

@copilot apply changes based on the comments in this thread

Agent-Logs-Url: https://github.com/bradygaster/squad/sessions/f521e322-ed1a-4c87-af67-32ebfa106315

Co-authored-by: bradygaster <41929050+bradygaster@users.noreply.github.com>

Copilot AI commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

@copilot apply changes based on the comments in this thread

Implemented in ab256ef: narrowed --state-backend docs to watch/triage, updated Git Notes “Branch-switch safe” to ⚠️, and changed the External State link to ./external-state.md.

Copilot AI requested a review from bradygaster April 17, 2026 22:11
@bradygaster bradygaster merged commit 15a05fa into dev Apr 17, 2026
3 of 4 checks passed
Copilot stopped work on behalf of bradygaster due to an error April 17, 2026 22:27
tamirdresher pushed a commit that referenced this pull request Apr 18, 2026
Extend StateBackend interface with delete() and append() methods.
Implement for all three backends (worktree, git-notes, orphan).
Add SquadStateContext and resolveSquadState() factory to the resolution
module so any command can resolve the configured backend once at entry.
Add comprehensive docs for state backends feature.

This is Phase 1 of making state backends squad-wide (not just watch).
Individual CLI commands will be migrated to use SquadStateContext in
follow-up PRs.

17 new tests (60 total for state-backend).

Closes #996

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: add user-facing documentation for state backends (git-notes, orphan-branch)

4 participants