fix(herdr-lab): place --session before the child-argv delimiter and refuse ambiguous delimiter shapes - #1
Merged
Amplify-Logic merged 4 commits intoJul 18, 2026
Conversation
`agent start ... -- <child argv...>` always got a trailing --session appended after --, so Herdr never consumed it and the child process received it instead - meaning Herdr could fall through to the live default session for agent-start calls. fm_herdr_lab_raw now places exactly one --session immediately before -- for that shape and still appends it for every ordinary call. fm_herdr_lab_cli rejects multiple delimiters, a delimiter on any command other than agent start, and agent start without a delimiter plus non-empty child command, before any Herdr call is made. Updated the brief scaffold and backend doc wording that claimed the selector is always trailing.
…pse raw invocation
This was referenced Jul 22, 2026
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.
Intent
Fix bin/fm-herdr-lab.sh so 'run agent start ... -- ' places --session before the child-argv delimiter (Herdr consumes it instead of the child), reject ambiguous/unsafe delimiter shapes before invoking Herdr, and update the brief/doc wording that claimed the selector is always trailing.
What Changed
bin/fm-herdr-lab.shnow splitsrunarguments on the first literal--: foragent start ... -- <child argv>it injects--session <name>before the delimiter so Herdr consumes it instead of the child process, while ordinary calls still get it appended; everything after the first--(including further--tokens) passes through to the child untouched.runcommand refuses ambiguous or unsafe delimiter shapes before invoking Herdr: a delimiter on any command other thanagent start, an option immediately before the delimiter (a value-taking option could swallow the injected--session),agent startwith a delimiter but no child command,agent startwithout any delimiter, and a caller-supplied--sessionanywhere before the delimiter.tests/fm-herdr-lab.test.shpins the accepted and refused shapes.bin/fm-brief.shanddocs/herdr-backend.mdno longer claim the session selector is always trailing; they now describe the helper as placing--sessionon every call (before the child-argv delimiter foragent start), with the brief test updated to match.Risk Assessment
✅ Low: The follow-up commit cleanly implements the requested first-delimiter-only contract with an exact regression test, removes no safety guard that pre-delimiter checks don't already cover, and leaves the header, docs, and tests consistent with the actual behavior.
Testing
Completed 1 recorded test check.
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 2 issues found → auto-fixed ✅
bin/fm-herdr-lab.sh:181- The multiple-delimiter refusal counts literal--tokens inside the child argv, so a legitimate child command that itself contains--(e.g.run <s> agent start probe -- npm run build -- --flag) is refused. This contradicts the header comment's claim that 'the opaque child argv itself passes through untouched' (line 26), and the error rationale ('could shift a lifecycle operation past the guard') does not apply to a--after the first delimiter, since splitting and all guards key only off the first--. If the restriction is intentional fail-closed behavior, consider tightening the header wording; if not, count only pre-child delimiters.bin/fm-herdr-lab.sh:159- The option-immediately-before-delimiter guard (refusing e.g.agent start --some-flag -- child) also rejects boolean flags that could never swallow the injected--session, and only inspects the single argument adjacent to the delimiter, so a hypothetical greedy multi-value Herdr option two positions back could still absorb the injected selector. As a shell-side heuristic this is a reasonable fail-closed best effort and is documented and tested as such; noting the boundary of the guarantee, no action needed.🔧 Fix: only treat first -- as delimiter; child argv untouched
✅ Re-checked - no issues remain.
⏭️ **Test** - skipped
command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.