Two-layer upgrade recreates casting state in working tree while hooks forbid committing it
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 45/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- git, node.js, typescript
研究方向
Start by tracing the two-layer upgrade path and the StateBackend behavior described in docs/src/content/docs/features/state-backends.md; inspect the listed install-hooks.ts file and the casting references in .squad-templates/squad.agent.md, .squad-templates/casting-reference.md, and templates/skills/coordinator-source-of-truth/SKILL.md. Determine whether casting files are mutable orphan-branch state or working-tree configuration before changing behavior. Done means upgrade behavior, agent instructions, and the hook agree on one source of truth.
由索引模型根據 Issue 內容生成。
描述
Bug: two-layer squad upgrade recreates .squad/casting/ state in the working tree, while the installed hooks treat it as orphan-branch-only state
When using the two-layer state backend, squad upgrade --state-backend two-layer installs the Git hooks correctly, but it also recreates the following files in the normal working tree:
.squad/casting/history.json
.squad/casting/policy.json
.squad/casting/registry.json
This appears inconsistent with the pre-commit hook installed by Squad.
Installed pre-commit behavior
The generated pre-commit hook contains:
# WI-1: Guard against accidentally committing two-layer mutable state into the
# working tree. If the user has staged any .squad/ paths that are owned by the
# two-layer/orphan backend (decisions.md, agents/*/history.md, casting/, routing/),
# warn and abort so the state stays on the squad-state orphan branch.
if [ -z "$SQUAD_SYNC_ACTIVE" ]; then
STAGED=$(git diff --cached --name-only 2>/dev/null | grep -E '^\.squad/(decisions\.md|agents/.+/history\.md|casting/|routing/)' || true)
if [ -n "$STAGED" ]; then
echo "⚠ squad pre-commit: refusing to commit two-layer state into the working tree." >&2
echo " These paths belong on the 'squad-state' orphan branch, not in your normal commits:" >&2
echo "$STAGED" | sed 's/^/ /' >&2
echo " Use 'git restore --staged <path>' to unstage, or set SQUAD_SYNC_ACTIVE=1 to bypass." >&2
exit 1
fi
fi
The hook therefore explicitly considers all of .squad/casting/ to belong on the squad-state orphan branch, not in normal commits.
However, immediately after running:
squad upgrade --state-backend two-layer
the upgrade process recreates:
.squad/casting/history.json
.squad/casting/policy.json
.squad/casting/registry.json
in the normal working tree.
This leaves the repository in a confusing state where Squad itself creates files that its own hook says should not exist as normal working-tree state.
There is a second inconsistency in squad.agent.md
The current .squad-templates/squad.agent.md also explicitly lists these files as cast sources:
## Cast sources
- `.squad/casting/registry.json`
- `.squad/casting/history.json`
- `.squad/casting/policy.json`
The current source-of-truth documentation similarly identifies these paths as authoritative/derived casting state.
This raises an important question for the two-layer backend:
Where is an agent supposed to read these files from?
If .squad/casting/* is mutable two-layer state and belongs only on the squad-state orphan branch, those files should normally not be present in the checked-out working tree.
But the generated agent instructions currently point directly to working-tree paths such as:
.squad/casting/registry.json
That seems incompatible with the storage semantics enforced by the hook.
Steps to reproduce
- Clone an existing Squad repository configured to use the two-layer backend.
- Ensure the existing
squad-statestate is available. - Run:
squad upgrade --state-backend two-layer
- Observe that Squad installs the expected Git hooks.
- Observe that Squad also creates:
.squad/casting/history.json
.squad/casting/policy.json
.squad/casting/registry.json
in the working tree.
- Stage one of those files.
- Attempt to commit.
The Squad pre-commit hook refuses the commit because .squad/casting/ is classified as two-layer state belonging on squad-state.
Expected behavior
The two-layer model should have one consistent source of truth.
If casting/ is mutable state owned by squad-state, then:
squad upgrade --state-backend two-layershould not recreate the runtime casting files in the normal working tree.- State should be read/written through the two-layer
StateBackend. - The generated
squad.agent.mdshould not instruct agents to directly use working-tree paths that are intentionally absent. - Agent/coordinator access to casting state should go through the appropriate state abstraction or materialization mechanism.
Alternatively, if these three casting JSON files are intentionally supposed to exist in the normal working tree, then the pre-commit hook is too broad:
^\.squad/(...|casting/|...)
and needs to distinguish between working-tree configuration and mutable orphan-branch state.
Why this matters
This is particularly noticeable when onboarding another team member.
squad upgrade --state-backend two-layer is useful because it correctly installs the local Git hooks that are not transferred by git clone.
However, running the upgrade also recreates mutable casting files locally. The developer is then left with files that:
- Squad itself created,
- the current agent instructions reference,
- but Squad's own pre-commit hook says must not be committed to the working tree.
It is therefore unclear whether the correct action is to delete them, leave them untracked, or retain them as local materialized state.
For a shared two-layer Squad repository, that ambiguity can easily result in different developers having different casting state in their working trees.
Related documentation/code
The current repository appears to acknowledge part of this problem already.
The state-backend documentation notes that files can reappear if code writes directly to disk rather than through StateBackend:
A tool, editor save, or agent code path that writes directly via
fs.writeFile(bypassingStateBackend) will recreate the file on disk.
The upgrade path itself appears to be causing effectively the same situation for the casting files.
Relevant locations in the current dev branch include:
packages/squad-cli/src/cli/commands/install-hooks.ts
docs/src/content/docs/features/state-backends.md
.squad-templates/squad.agent.md
.squad-templates/casting-reference.md
templates/skills/coordinator-source-of-truth/SKILL.md
Suggested resolution
I think the intended model should be clarified first:
If .squad/casting/* is two-layer mutable state
Then preferably:
- Do not create
casting/history.json,casting/registry.json, or runtimecasting/policy.jsonin the working tree when the backend istwo-layerororphan. - Ensure upgrade/init operations use
StateBackendrather than writing these files directly. - Update
squad.agent.mdso agents do not depend on directly reading these working-tree paths. - Keep the existing pre-commit protection.
If some casting files are actually working-tree configuration
Then:
- Clearly separate configuration from runtime state.
- Adjust the pre-commit hook so it does not reject the configuration files.
- Document which casting files are committed and which belong on
squad-state.
At the moment the installed hook, upgrade behavior, and generated agent instructions appear to describe three different ownership models for the same files.
- 主要語言
- TypeScript
- 星號
- 3.4k
- 分支
- 516
- 平均合併
- 1 天 15 小時
- 30 天內合併 PR
- 116
環境準備
- 提供 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
github/squad 的其他 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 84/100
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 77/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 82/100
vercel-labs/ui#809 ·
維護者通常 1 天內回覆
-
bot:ai-assisted component:platform-js status:untriaged
難度 1/5 1 小時以內 新手友好度 74/100
midnightntwrk/platform-js#38 ·
-
[bug] Second false positive on high-cost plugin alert: detection only compares patch entry id, community plugin dsh-auto | [bug] 高成本插件告警第二次误报:检测只比对 patch 条目 id,社区插件 dsh-auto-review 被认成 @deepseek-ai/dsh-experimental-auto-review可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉
難度 2/5 1-3 小時 新手友好度 68/100
ranxianglei/billion-context#7068 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
mybigday/whisper.rn#348 ·
-
難度 2/5 1-3 小時 新手友好度 78/100
six-group/six-webcomponents#600 ·