Repository navigation
Validate hcoord spawn arguments before any effect and name the started agent again - #243
Merged
Merged
Conversation
… again A spawn whose native arguments the chosen kind cannot take was refused only after hcoord had created the worktree, the workspace and its shell pane, so the same intent could not be retried and a person cleaned up by hand (#237). The CLI now checks the name, kind and native arguments before it registers a --parent here pane or writes a letter, and the daemon checks them again before it reserves the intent. A leading executable name after -- (for example `-- claude` under the default `codex` kind) is refused with the --kind to pass, and `hcoord agent spawn --help` prints the usage. Herdr can report the agent hcoord has just started without the name it was started under, and the lineage step then refused it as a different execution although the agent was running (#236). Directly after its own start in the pane the intent owns, hcoord names an unnamed agent of the intended kind again and logs that it did. A later retry cannot tell a lost name from a replaced agent, so it still refuses and names the rename command a person runs. Closes #236 Closes #237
…ost-name retry The spawn help showed --session as optional and said --machine always needs --repo and --branch; it is required without --parent here, and only a machine other than the parent's needs a worktree. A name must also start with a letter. The README now says a retry that finds the child unnamed refuses and how a person names it.
…d start or on retry Naming ran only when agent start exited 0. A prompt passed as a native argument can keep the agent working past readiness: agent start then times out, the pane's agent has no name, and the same-intent retry refused it, so one spawn still did not write the lineage (observed 2026-09-28). A name Herdr dropped after the rename was also never repaired. Right after its own start, confirmed or not (only Herdr's busy refusal proves nothing started), hcoord records the pane's terminal and any reported session as the started execution. Then, and again at the start of every same-intent retry, it names an unnamed agent only when pane, kind, terminal and recorded session match that execution. An unnamed agent in another terminal or session is refused as a replacement and never renamed; an intent saved before this record keeps the manual rename hint. A lone word after -- is a prompt or task, so the leading-executable check now refuses an executable name only when arguments follow it.
yansfil
added a commit
that referenced
this pull request
Sep 28, 2026
…one test fixtures (#245) Related: 2a8e6d1 is on `feat/overview-lenses` (#238); the maintenance guard was found while working on #242. This lands both on `main`. ## Summary - The clone test fixtures (`hide-host/tests/clone.rs`, `herdr-core/src/runtime/tests/repository_clone.rs`) commit, then run a local `git clone --bare`. - `git commit` starts a detached `git maintenance run --auto`, which can pack and prune loose objects while the clone is still copying them. - On macOS CI runners this fails a random clone test with "failed to copy file ... No such file or directory" in the fixture, before the code under test runs. - Tonight it failed the `rust workspace` lane of #242 (twice), #243 and #244, always at `clone.rs:24`. - The fixtures' `git` calls now turn off auto maintenance and auto gc, and the bare origin is cloned with `--no-local` (a pack through Git's transport, no file copy). Test-only. ## Review - **Please decide**: whether landing this on `main` before #238 is fine; 2a8e6d1 is identical to the commit on `feat/overview-lenses`, so #238 merges over it cleanly. - **Files to watch**: `herdr-core/src/runtime/tests/repository_clone.rs` - preventive: the same fixture shape, not observed failing. ## Evidence - **Confirmed**: `cargo test -p hide-host --test clone` passes 5/5 locally; the hide-host race reproduced locally under forced background gc before the maintenance guard and not after (measured while working on #242). - **Not confirmed**: the flake rate on CI after the change beyond this PR's own runs; the herdr-core fixture never reproduced. **AI tooling**: mostly AI tools; the diff is three cherry-picked commits, compared by hand.
…rt replace the recorded start A pane keeps its terminal while agents are restarted in it, so a retry that matched the terminal alone could rename a replacement: a `codex` start that timed out records no session, a person restarts the agent in that pane, and the retry named it, sent the first turn and bound it as the child. The call that started the agent still names it on the terminal match; a later retry renames only when a recorded session exists and matches the agent's, and otherwise refuses with the manual rename a person runs. A --resume-start after the first agent exited launched a new agent and then refused its new session against the recorded one, and every later retry failed the same way. A deliberate --resume-start now clears the recorded start before it launches.
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.
Related: #236, #237
Summary
Closes #236. Closes #237.
identity_conflict) although the agent was running.agent starttimes out, and the pane's agent is unnamed.herdr agent rename) when pane, kind and terminal (and any recorded session) match.--resume-startclears the recorded start of an agent that is gone before it launches a new one.--parent herepane, writes a letter, or reserves an intent.--(such as-- claude --dangerously-skip-permissionsunder the defaultcodexkind) is refused, and the error names the--kindto pass.hcoord agent spawn --helpprints the spawn usage, including--kindand howclaudeandcodexarguments are passed.No screen changes.
Review
So a
codexstart that timed out (no session yet) still needs a manualherdr agent renameon retry after a person checks the pane.An unnamed agent in another terminal or session is refused as a replacement and never renamed.
A retry with different arguments on the same intent remains
intent_conflict.--(for example the promptclaude) is accepted as a prompt or task.So
-- codexunder thecodexkind still sendscodexas the task.plugins/hcoord/src/hcoord/transport.ts(spawn sequence): the failure path.An unconfirmed start now continues like a retry would, and only
agent_pane_busystops it.plugins/hcoord/src/hcoord/herdr.ts(observeStartedAgent,nameSpawnedAgent,inspectSpawnedAgent): identity binding over the Herdr contract (agent.renameis in the pinned schema).plugins/hcoord/src/hcoord/service.ts(agent.spawn.started,agent.spawn.start_reset): new ledger steps.The spawn event budget goes from 7 to 8 slots.
startedrefuses a terminal or session that differs from the first observation, andstart_resetclears it on--resume-start.observeStartedAgentrecords nothing whenagent getdoes not answer within 2 s, or when the daemon dies before the ledger write.Such an intent behaves like one saved before this change.
--resume-startand at reserve.An intent reserved before this change with an executable name followed by flags now fails on rerun, even after its pane exists.
Evidence
herdr agent start ... -- --dangerously-skip-permissions --effort high "<prompt>"timed out ({"code":"timeout"}) because Claude Code went straight to work.agent_not_founduntilherdr agent renamewas run.HCOORD_HOME, real Claude Code, this branch):timeout(exit 1) and clears the name.With it, the spawn exits 0, logs
hcoord.spawn_name_restored, writes lineagewritten, andagent getshows the name andparent_pane.On
main, that case fails with the issue'sidentity_conflict.I could not make a real start time out on demand.
codex, and a misplacedcodextask) exit 2.Worktrees, workspaces, intents, participants, the outbox and branches are all unchanged; on
mainthe same command left a worktree and a workspace behind.timeoutoragent_not_readyname and register the agent.spawn_uncertain/name_agent, and a retry renames and binds.--resume-startbinds the new session; without the reset this case fails.--repo --branchnever callsworktree create.--parent herevalidates before inspecting the pane, and--helpprints the spawn usage.check-no-attribution.py.clone.rsfixture flake is fixed onmainby Keep background git maintenance and local object copies out of the clone test fixtures #245, which is merged into this branch.The last run failed
desktop/e2e/add-project.spec.ts:134in its cleanup (rmdirENOTEMPTY), outside this diff.AI tooling: mostly AI tools; the live runs above were checked by reading Herdr's
agent getoutput, the hcoord ledger events andgit worktree listdirectly.