Repository navigation
fix(composer): make composer-state classification locale-invariant - #370
zachlandes wants to merge 9 commits into
Conversation
7681871 to
1014548
Compare
The composer-state readers stripped a leading prompt glyph with
${stripped#?}, which removes a single byte under a C/POSIX locale and
leaves two stray bytes of the three-byte ❯ behind, so an idle composer
was misread as pending. Match and strip the exact glyph literal instead,
then trim any following whitespace. cmux, herdr, and orca share the
pattern; herdr additionally keeps its › prompt glyph.
Add a colocated LC_ALL=C regression test asserting the idle ghost
placeholder still reads empty, so a refactor back to byte-count stripping
cannot regress silently on C/POSIX-locale hosts.
…composer classifier BREAKING: FM_BACKEND_HERDR_BARE_PROMPT_RE is retired and no longer honored. Setting it warns loudly on stderr instead of taking effect. The replacement is FM_BACKEND_HERDR_BARE_PROMPT_GLYPHS, a whitespace-separated list of literal prompt glyphs. * The honest cost: this changes the accepted FORMAT of a documented environment override, on a repo we do not own. docs/configuration.md documented the regex spelling, so an operator who wrote one against that documentation loses it. That is a real cost, not a cleanup. * The cost was unavoidable, because the regex form cannot be made locale-safe. Any regex has to reach grep, and under the C/POSIX locale bin/fm-supervise-daemon.sh runs with, an ERE bracket class over multibyte glyphs degenerates into a byte class. Every box-drawing glyph starts with byte E2, so a composer box's own border row matched as a bare prompt row, outranked the live composer in the bottom-most-match scan, and the composer read empty while the human's unsubmitted text sat right above it. The away-mode injector would have typed an escalation over real input. The only alternative was forcing a locale on the daemon. * Mitigating: the knob was set nowhere except its own default and one doc example. It had no in-repo consumer. * Mitigating: the knob already contradicted its own documentation. It was documented as controlling the recognized prompt glyphs, but was honored only for herdr's structural row detection and never for classification, so an added glyph's idle composer wedged on pending forever. Threading the set through to the shared classifier makes it mean what it always claimed to mean.
…ode type-strip warning
…locale-safe matching
1014548 to
4100fbc
Compare
|
Thanks for the PR! This branch currently has a merge conflict with the base branch. When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again. Noted for firstmate#370 at |
|
Automated reminder: this PR still looks blocked on a rebase or merge conflict fix. If you are still interested, please rebase onto the current base branch, resolve the conflict, and push. If I do not hear back, I may close this as inactive. |
|
I am closing this because it has been waiting on a rebase or merge-conflict fix since 2026-07-15, and I have not seen a comment or push since then. If you still want to keep working on this, please reopen it or open a new PR and mention this one. Happy to take another look when there is an update. |
Intent
Make firstmate's composer-state classification locale-invariant, so the away-mode supervisor cannot misread a pane's composer under the C/POSIX locale its daemon actually runs with.
Two separate faults, one root cause - a multibyte glyph treated as bytes under a C locale:
bin/fm-composer-lib.sh stripped a leading prompt glyph by CHARACTER COUNT (${content#?}). Under C/POSIX that removes a single BYTE, orphaning two bytes of the three-byte U+276F glyph. The backends' idle-placeholder regexes are anchored, so the stray byte defeats the anchor and an idle composer reads 'pending' instead of 'empty' - which makes the away-mode injector defer every escalation indefinitely (the overnight wedge).
bin/backends/herdr.sh matched the bare agent prompt with a grep bracket class ('^[❯›]'). Under C/POSIX that degenerates into a BYTE class, and every box-drawing glyph leads with the same byte, so the composer box's own bottom border row falsely matches as a bare prompt row. herdr keeps the bottom-most match, so the border row outranks the real composer, strips to empty, and the composer reads 'empty' while the human's unsubmitted text sits right above it - the false-EMPTY direction, where the injector would type over real input.
The fix replaces both byte-fragile forms with literal glyph sets matched by bash 'case', so no locale-sensitive grep or byte arithmetic remains anywhere in the glyph path. The glyph set becomes configurable - fleet-wide, and per-herdr layered on top of the fleet-wide default - and is threaded through the shared classifier so an operator-added harness glyph is honored for classification, not just for structural row detection (previously it was honored for detection only, so an overridden harness's idle composer wedged on 'pending' forever).
Deliberate decisions a reviewer should know about:
What Changed
case:bin/fm-composer-lib.shno longer strips a leading prompt glyph by character count (${content#?}, which removes a single byte under C/POSIX and orphans two bytes of a three-byte glyph), andbin/backends/herdr.shno longer matches bare prompts with a grep bracket class (^[❯›], which degenerates into a byte class where every box-drawing glyph shares the leading byte, so a composer border row outranks the real composer). The only remaining regex — the per-harness idle placeholder — is now matched under a pinnedLC_ALL=Cso a hand-tested pattern behaves the same inside the C-locale supervise daemon.FM_COMPOSER_AGENT_GLYPHSfleet-wide, with herdr'sFM_BACKEND_HERDR_BARE_PROMPT_GLYPHSlayering on that default and handed tofm_composer_classify_contentas well as to structural row detection, so a configured glyph is honored for classification rather than detection only. Shell prompt glyphs (>,$,%,#) are refused at three layers, including the shared match chokepoint, and a set that sanitizes down to nothing falls back to the built-in❯ ›instead of emptying.FM_BACKEND_HERDR_BARE_PROMPT_REis retired: it now warns loudly on stderr instead of being silently ignored. With no knob set, behavior is byte-identical to before for every backend.tests/fm-composer-lib.test.shandtests/fm-backend-herdr.test.sh, each pinning the locale in a child process because anLC_ALL=C <shell function>prefix does not re-runsetlocaleon bash 3.2. Along the way, repaired two pre-existing fixture faults that were failing the suite locally (a missing composer-lib sibling in the gotmp fixture, and two Pi tests that did not tolerate node's experimental type-stripping warning), and updated the herdr, configuration, and harness-adapter docs to the new knobs.Testing
Pipeline
Updates from git push no-mistakes
⏭️ **intent** - skipped
Step was skipped.
⏭️ **Rebase** - skipped
Step was skipped.
⏭️ **Review** - skipped
Step was skipped.
⏭️ **Test** - skipped
Step was skipped.
⏭️ **Document** - skipped
Step was skipped.
⏭️ **Lint** - skipped
Step was skipped.
✅ **Push** - passed
✅ No issues found.