Skip to content

fix(bin): send harness slash commands to secondmates unmarked - #17

Merged
Hozzy02 merged 1 commit into
mainfrom
fm/fm-send-slash-unmarked
Sep 25, 2026
Merged

Hozzy02 merged 1 commit into
mainfrom
fm/fm-send-slash-unmarked

Conversation

@Hozzy02

@Hozzy02 Hozzy02 commented Sep 25, 2026

Copy link
Copy Markdown
Owner

Intent

Bug seen 2026-09-25: FM_HOME= bin/fm-send.sh "/clear" wrapped the text in the from-firstmate carrier (bin/fm-operational-input.sh), so the Claude second mate received it as chat and the slash command never ran; only sending to the explicit backend target (e.g. default:wH:p2) worked. Fix: when the text is a harness slash command (or a codex $skill invocation) sent to a kind=secondmate task selector, send it unmarked, exactly like the explicit-target path, while ordinary text stays marked. Keep pending-reply expectations off for these (no pending-reply record created). Add colocated tests for both shapes (slash command, codex $skill); update the fm-send header and any doc that states the marking rule. Decisions made: a command qualifies only when its leading token starts with a lowercase ASCII letter, contains only [A-Za-z0-9._:-], and ends at whitespace or end of text, so absolute paths (/tmp/x), capitalized slash-led prose, $5/month and $HOME stay marked ordinary text; the $ form counts only for a harness=codex target, matching the existing codex-scoped popup-settle rule; explicit character lists are used instead of [a-z] because locale collation made [a-z] match uppercase on macOS; the --key path, crewmate/scout targets, and explicit targets are unchanged; remote secondmates are covered because classification happens in the parent fm-send before the remote hop. docs/agent-control.md keeps lifecycle control (exit/interrupt) on fm-control even though slash commands are no longer marked. Repo rules: one sentence per line in Markdown, no agent co-author on commits, shellcheck-clean bin scripts, commit subject plus at most 3 body lines, PR description at most 5 lines plus footer.

What Changed

  • bin/fm-send.sh now sends a leading harness command to a kind=secondmate selector unmarked and without a pending-reply record. This covers a slash command like /clear, and a $skill invocation when the target runs codex. Ordinary text, absolute paths, $HOME, and capitalized prose are still marked.
  • Added tests/fm-send-secondmate-marker.test.sh cases for the slash-command and codex $skill shapes. They pass under both the C and UTF-8 locales.
  • Updated the fm-send header, docs/agent-control.md, and docs/architecture.md with the new marking rule. Lifecycle control (exit and interrupt) still goes through fm-control.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The classification is narrow and runs before the --key, remote and explicit-target branches. TARGET_HARNESS is resolved before the check, and remote sends travel over the explicit endpoint path, so no marking happens there. No pending-reply record is created for unmarked commands, and the tests and docs match the stated intent.

Testing

I ran the colocated fm-send secondmate-marker test at the target commit and it passed in both the en_US.UTF-8 and C locales. It checks that slash commands and codex $skill invocations to a secondmate go out unmarked with no pending-reply record, while path-like and $-led prose stays marked. Running the same test against base fm-send.sh fails with the reported [fm-from-firstmate] /clear wrapping, which confirms the bug existed before the fix. The doc updates match the intent, and I left the worktree clean.

Evidence: Target-commit test transcript (fm-send secondmate marker)

ok - fm-send: a slash command to a secondmate is sent unmarked with no pending reply, while slash-led text stays marked ok - fm-send: a codex $skill invocation to a secondmate is unmarked, while $-led text stays marked

ok - fm-send: a kind=secondmate target gets the from-firstmate marker and corr prepended
ok - fm-send: an exact kind=secondmate task id is marked with corr exactly once
ok - fm-send: a slash command to a secondmate is sent unmarked with no pending reply, while slash-led text stays marked
ok - fm-send: a codex $skill invocation to a secondmate is unmarked, while $-led text stays marked
ok - fm-send: exact-id and stable-label kind=ship selectors are sent unmarked
ok - fm-send: explicit endpoints stay unmarked with or without local metadata
ok - fm-send: the --key path carries no marker (no literal text is typed)
ok - fm-send: the marker is '[fm-from-firstmate]' + terminal-safe U+2063, while direct captain text stays unmarked
ok - fm-marker: from-firstmate transformation is idempotent
ok - fm-send: marked secondmate payload preserves trailing newline bytes
Evidence: Same test against base a0c8f92 fm-send.sh (shows the original bug)

not ok - exact-id /clear to a secondmate: expected the bare command, got [fm-from-firstmate]⁣corr=929c35ca49a01ba6 /clear

ok - fm-send: a kind=secondmate target gets the from-firstmate marker and corr prepended
ok - fm-send: an exact kind=secondmate task id is marked with corr exactly once
not ok - exact-id /clear to a secondmate: expected the bare command, got
--- bytes ---
           [   f   m   -   f   r   o   m   -   f   i   r   s   t   m   a
           t   e   ] 342 201 243   c   o   r   r   =   9   2   9   c   3
           5   c   a   4   9   a   0   1   b   a   6       /   c   l   e
           a   r                                                        

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ℹ️ bin/fm-send.sh:364 - The command token stops at any whitespace, newline included. So a multi-line message whose first line is a bare command (e.g. "/clear\nthen summarize X") goes out unmarked with its trailing prose, and gets no pending-reply record. A single-segment lowercase path like "/usr is full" is also treated as a command. Both follow the documented decision rule (the token ends at whitespace or end of text). This note just flags the edge; no change is required.
✅ **Test** - passed

✅ No issues found.

  • bash tests/fm-send-secondmate-marker.test.sh at the target commit (all 10 cases, including the 2 new ones)
  • LC_ALL=en_US.UTF-8 bash tests/fm-send-secondmate-marker.test.sh and LC_ALL=C ... to check that the explicit character lists behave the same in both locales
  • Temporarily swapped in bin/fm-send.sh from base a0c8f92 and re-ran the test; it fails with the marked [fm-from-firstmate]⁣corr=... /clear bytes, which matches the reported bug; restored the target file afterward and confirmed a clean worktree
  • Read the diffs of the fm-send header, docs/agent-control.md and docs/architecture.md against the intent's rules: marking rule updated, lifecycle control stays on fm-control, one sentence per line
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

A /command (or codex $skill) through a secondmate selector was wrapped in the
from-firstmate carrier, so the harness read it as chat; send it bare instead.
@Hozzy02
Hozzy02 merged commit 311af1b into main Sep 25, 2026
13 checks passed
@Hozzy02
Hozzy02 deleted the fm/fm-send-slash-unmarked branch September 26, 2026 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant