Repository navigation
refactor(agents): key Herdr ownership by terminal_id - #272
Merged
Merged
Conversation
Record workspaces and agents from the result of one simple direct herdr call (workspace create, worktree create, agent start) instead of claiming agent names before the command runs. Prompt and close are allowed only when the live terminal matches the recorded terminal_id, which closes the stale-name and shared-workspace holes. Trim the matching skill text and split the ownership tests to stay within the file-length budget. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Expire records from the successful close or remove result instead of before the command runs, match agents by terminal and agent session, limit worktree remove to a bare --workspace on a linked worktree, and treat any global option as a server override. Register the PostToolUse hooks for workspace close and worktree remove, and restore the gh api quoting rule next to the single-call rule. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Hold the session lock while a create, start, close, or remove result updates the record, accept the real `ok` response type for workspace close, and expire a removed worktree by the workspace_id in its result. Simplify the worktree path handling and the agent match. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
Herdr の所有モデルを,名前ベースの lane と terminal_id ベースの primary の二本立てから,terminal_id をキーにした単一のモデルへ統一する.あわせて skill の文章を短くする.
背景
名前ベースのモデルには次の 2 つの穴があった.
agent startが失敗した場合や agent が終了した場合でも名前が記録されたまま残り,同じ名前で起動した別セッションが,prompt の自動承認と workspace の close/remove の自動承認を受けてしまう.変更内容
herdr呼び出し(workspace create,worktree create,agent start)が作ったものだけとし,terminal_id で識別する.記録は PostToolUse で結果 JSON から行い,実行前には保存しない(実行前の「同名の生きた agent がいれば拒否」は維持).agent prompt: 記録された名前かつ,生きた agent の terminal_id と agent session が記録と一致する場合のみ許可.workspace closeとworktree remove --workspace: 記録済みで,id・label・path が一致し,記録済みルート terminal が存在し,その中の全 agent が記録済みの場合のみ許可.それ以外は ask.workspace closeとworktree removeの PostToolUse フックを登録した.worktree removeは--workspace <ID>のみの形で,リンクされた worktree に限り自動承認する.typeが想定どおり(close は実際のok)の場合のみ記録・失効し,worktree removeは結果のworkspace_idで失効させる.agents/hooks.jsonにworktree create,agent start,workspace close,worktree removeの PostToolUse フックを追加した.branches.mdとherdr-delegation/SKILL.mdの文章を短縮した.gh apiの引用符の項目は,単一呼び出しのルールの直後に置いた.test_herdr_ownership_workspaces.pyと共有ヘルパーherdr_runtime.pyに分割した.確認
uv run --frozen pytest tests/agents: 1958 passedCloses #270
🤖 Generated with Claude Code