Two-layer upgrade recreates casting state in working tree while hooks forbid committing it
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 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時間
- マージ済み PR(30日)
- 116
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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
-
bot:ai-assisted component:platform-js status:untriaged
難易度 1/5 1時間未満 初心者へのやさしさ 74/100
midnightntwrk/platform-js#38 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ranxianglei/billion-context#7068 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
mybigday/whisper.rn#348 ·
-
enhancement severity:low
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
Battle-Cattle/BCUK-Bot-4#1075 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
ilan-pinto/roaring-lions#1552 ·
メンテナーはふだん 1 日以内に返信