feat: wire state backends into all squad operations (worktree, git-notes, orphan, two-layer)#1004
feat: wire state backends into all squad operations (worktree, git-notes, orphan, two-layer)#1004tamirdresher wants to merge 1 commit intodevfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the Squad SDK’s state backend system toward squad-wide applicability by adding new backend capabilities (delete/append), introducing a single entry-point resolver (resolveSquadState()), and documenting backend behavior and configuration.
Changes:
- Add
delete()andappend()to theStateBackendinterface and implement them for Worktree, Git Notes, and Orphan Branch backends. - Introduce
SquadStateContext+resolveSquadState()to resolve paths and the active backend in one call, and export them via the SDK barrel. - Add comprehensive docs plus expanded test coverage for delete/append and
resolveSquadState().
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
packages/squad-sdk/src/state-backend.ts |
Extends StateBackend and implements delete()/append() across all backends. |
packages/squad-sdk/src/resolution.ts |
Adds SquadStateContext and resolveSquadState() to resolve backend + paths together. |
packages/squad-sdk/src/index.ts |
Exports resolveSquadState and SquadStateContext from the public SDK API. |
test/state-backend.test.ts |
Adds delete/append tests for all backends and integration tests for resolveSquadState(). |
docs/src/content/docs/features/state-backends.md |
New feature documentation covering configuration, tradeoffs, inspection, SDK API, and security. |
.changeset/state-backend-global.md |
Declares a minor SDK release and summarizes the new API surface/behavior. |
97e5cee to
a7c230e
Compare
🛰️ Mission Control Review — PR #1004Reviewers: Flight (Architecture), EECOM (Implementation), FIDO (Quality) Findings1. 🔴 [Blocking] OrphanBranchBackend.read() is still lossy
Recommendation: Make orphan 2. 🔴 [Blocking] resolveSquadState() is wrong for git worktrees
Recommendation: Derive git cwd from the actual current worktree root, not from 3. 🟡 [Non-blocking] Orphan delete leaves phantom empty directories
Recommendation: Prune empty parents after delete; add a nested-delete test. Architecture Assessment
Verdict: Good foundation. Fix the two blocking issues before merge. 🚀 — Flight, EECOM, FIDO · Mission Control Squad |
2932646 to
cd94d7f
Compare
E2E Validation Report - see PR description for full details |
E2E Validation ReportHow tests were run
Results: 9/10 PASS, 1/10 PARTIAL
Key proofsGit notes work (Test 2): Orphan branch isolates state (Test 5): Feature branch PRs are clean (Test 6): Test 3 known issueAgent wrote git note to HEAD instead of root commit. The note IS functional (ref visible from all branches), but the root-commit anchor pattern wasn't followed. Template instruction clarity improvement for follow-up. |
9edd038 to
c1cdb48
Compare
c1cdb48 to
3e81270
Compare
|
Hey Tamir, any update on this backend? I'd really want to use this for our cncf project to keep the squad stuff out of the way :) |
feat: wire state backends into all squad operations
Closes #1003, closes #1013
What changed
Makes state backends work squad-wide with 4 options:
worktree(default),git-notes,orphan, andtwo-layer(the blog architecture).New:
squad init --state-backend <type>Auto-creates
squad-stateorphan branch for orphan/two-layer backends at init time.Backend comparison
worktreegit-noteswrite-note.ps1orphansquad-stateorphantwo-layerThe
two-layeroption implements the architecture from Tamir's blog: git notes for commit-scoped "why" annotations + orphan branch for permanent state. Ralph promotes notes withpromote_to_permanent: trueafter PR merge.Changes by package
SDK (squad-sdk):
StateBackendinterface: addeddelete()andappend()CLI (squad-cli):
squad init --state-backend <type>flag with orphan branch auto-creationcli-entry.tswires resolveSquadState after --state-backend parsingwatch/config.tsaccepts pre-resolved backendCoordinator (squad.agent.md):
Templates: notes-protocol.md, fetch.ps1, write-note.ps1
Docs: Quick start, migration guide, troubleshooting, coordinator integration table
E2E Test Results: 12/12 pass
Test 12 proof (init --state-backend two-layer):
stateBackend: "two-layer"set at initstate: promote team roster,state: promote auth decisionrefs/notes/commitswith promote_to_permanent entries