macOS support: capture resampling, private runtime directory, Metal and MLX engines #1

Open
opened 2026-11-15 22:55:15 +00:00 by piersdd · 1 comment
Owner

Problem Statement

herdr-dictate gives local speech-to-text dictation into the focused Herdr pane, but it runs on Linux only. The plugin manifest declares Linux as its one platform, and the microphone capture asks the device for 16 kHz mono directly, which CoreAudio devices do not offer. The four Apple Silicon Macs in the fleet (viper, viking, voyager, vega) therefore cannot dictate into a pane.

Two more problems appear as soon as the plugin runs on macOS:

  • macOS has no XDG_RUNTIME_DIR. The model server socket and its pid file then fall back to a predictable directory under /tmp that is created without an ownership or mode check. Another local user can own that directory first, receive the raw audio, and return text that is typed into the pane.
  • On the local path, toggle-send presses Enter without a check that an agent holds the pane. At a shell prompt the transcript runs as a command. The remote path already makes this check.

The operator also wants to know whether an MLX engine gives better latency or accuracy on Apple Silicon than the transcribe.cpp Metal backend that the crate already exposes as a feature.

Solution

A fork of herdr-dictate, at git.gen3.dev/piersdd/herdr-dictate, that runs on Apple Silicon macOS:

  • The microphone is opened at the format the device offers. A resampler converts the audio to 16 kHz mono before anything else sees it.
  • The default engine on macOS is the bundled transcribe.cpp engine, built with the Metal backend. It uses the same Parakeet model and the same settings as on Linux.
  • A second, opt-in engine runs the model with MLX in a separate model server process. The plugin starts and stops that process. The operator selects it with one setting.
  • All sockets live in one private runtime directory that the plugin creates with mode 0700 and verifies before use. There is no /tmp fallback on any platform.
  • toggle-send presses Enter on the local path only while an agent holds the pane, as the remote path does.
  • doctor reports the macOS-specific dependencies: microphone permission, the runtime directory, the Metal backend, and the MLX runtime when that engine is selected.
  • A measurement on one fleet Mac records latency and word errors for both engines. The result decides which engine the fleet uses.

Linux behaviour does not change, except for the runtime directory fallback and the local submit check.

User Stories

  1. As a Mac operator, I want to press the dictate key and have my words typed into the focused pane, so that I can talk to an agent on macOS as a Linux user can.
  2. As a Mac operator, I want the plugin to accept the microphone at its native sample rate and channel count, so that I do not have to configure an aggregate device or change system audio settings.
  3. As a Mac operator, I want a built-in MacBook microphone, a USB microphone, and a Bluetooth headset each to work, so that the input device I have selected in macOS is the one that records.
  4. As a Mac operator, I want the resampled audio to give the same transcript quality as a native 16 kHz recording, so that the port does not cost accuracy.
  5. As a Mac operator, I want the model to run on the Apple GPU through Metal, so that a short command comes back in well under a second.
  6. As a Mac operator, I want the Metal engine to fall back to the CPU when the GPU cannot be used, so that a dictation still completes.
  7. As a Mac operator, I want live typing to work on macOS, so that words appear at each pause while I am still talking.
  8. As a Mac operator, I want trailing silence to end a recording on macOS, so that I do not have to press the key a second time.
  9. As a Mac operator, I want the plugin to install on macOS by a source build with the Metal backend, so that I need no prebuilt binary.
  10. As a Mac operator, I want doctor to tell me that microphone permission is missing and to name the System Settings pane, so that a silent recording is not a mystery.
  11. As a Mac operator, I want doctor to say which process macOS attributes the microphone to, so that I grant the permission to the right application.
  12. As a Mac operator, I want a recording of pure digital silence to be reported as a probable permission denial, so that I do not raise the speech threshold to no effect.
  13. As a Mac operator, I want to select the MLX engine with one setting, so that I can compare it with the Metal engine without a rebuild.
  14. As a Mac operator, I want the plugin to start the MLX model server on the first dictation and stop it after the idle period, so that I run nothing by hand.
  15. As a Mac operator, I want a dictation that selects the MLX engine to fail before recording starts when the MLX model server cannot start, so that I do not speak into a recording that can never be transcribed.
  16. As a Mac operator, I want the replacement table and the whitespace collapse to apply to MLX transcripts, so that both engines give the same text rules and a dictated newline cannot submit a prompt.
  17. As a Mac operator, I want the MLX model to be downloaded at a pinned revision and verified against known digests, so that the model the server loads is the model the fork names.
  18. As a Mac operator, I want doctor to check the MLX runtime only when the MLX engine is selected, so that the default engine has no extra dependency.
  19. As a Mac operator, I want doctor to name the engine, the model, and the backend that answered, so that I can confirm which engine a measurement used.
  20. As a Mac operator, I want the status chip and watch output to work on macOS, so that my status line shows the dictation phase.
  21. As a Mac operator, I want remote delivery to a saved machine to work from macOS, so that I can dictate on a laptop into a pane on voyager.
  22. As a security reviewer, I want every socket and pid file in a directory that only my user can enter, so that another local user cannot read audio or inject text.
  23. As a security reviewer, I want the plugin to refuse a runtime directory that it does not own or that group or others can enter, so that a directory planted before first use is not trusted.
  24. As a security reviewer, I want serve-stop to signal only a pid read from the verified runtime directory, so that a planted pid file cannot make the plugin signal an arbitrary process.
  25. As a security reviewer, I want toggle-send at a local shell prompt to type the words and not press Enter, so that a misheard phrase cannot run as a command.
  26. As a security reviewer, I want the log to say when Enter was withheld because no agent held the pane, so that the behaviour is explainable.
  27. As a security reviewer, I want the MLX model server to bind its socket only in the verified runtime directory and to accept only the existing wire protocol, so that it adds no network listener.
  28. As a security reviewer, I want new dependencies to pass the existing licence and advisory gate, so that the fork keeps the upstream supply-chain posture.
  29. As a Linux operator, I want capture on Linux to keep the direct 16 kHz path when the device offers it, so that the port changes nothing for me.
  30. As a Linux operator, I want a device that offers no 16 kHz mono input to work through the resampler, so that the old "resampling is not implemented" error disappears.
  31. As a developer, I want toggle --from-wav to accept a WAV at any sample rate and channel count, so that I can drive a whole macOS-shaped dictation without a microphone.
  32. As a developer, I want the resampler to be pure functions over buffers, so that I can test it inline without a device.
  33. As a developer, I want the gate script to pass on macOS, so that I can run the same checks on a Mac as CI runs.
  34. As a developer, I want a macOS job in CI that builds with the Metal feature and runs the tests, so that the port cannot regress silently.
  35. As a developer, I want the capture, runtime directory, and submit-guard changes as separate commits that do not depend on the MLX work, so that I can offer them to upstream as pull requests.
  36. As the fleet owner, I want a written measurement of Metal against MLX on one fleet Mac, so that the engine choice rests on numbers.
  37. As the fleet owner, I want the fork to track upstream by a read-only upstream remote, so that upstream fixes can be merged and nothing is pushed to GitHub by accident.

Implementation Decisions

Platform

  • The fork supports Linux as today and macOS on Apple Silicon. Intel macOS is not a target.
  • The plugin manifest declares both platforms. The plugin id stays unchanged, so the diff against upstream stays small. A host installs either upstream or the fork, never both.
  • On macOS the install step always compiles from source with the Metal feature. The fork publishes no macOS release artifact.

Capture and resampling

  • The capture module remains the single platform boundary. It opens the default input device at 16 kHz mono when the device offers that format. Otherwise it opens the device's default input format.
  • A new streaming resampler in the audio module converts any input rate and channel count to 16 kHz mono 16-bit samples. It keeps state across frames, so frame boundaries add no clicks. It is band-limited, so a 48 kHz input does not alias.
  • The resampler comes from a pure-Rust crate with a permissive licence that passes the existing licence gate. No C dependency is added for it.
  • Everything after capture (silence detection, chunking, the meter, the engine) continues to see only 16 kHz mono samples. The 16 kHz target constant keeps its meaning.
  • The WAV source accepts any sample rate, any channel count, and 16-bit or float samples. It passes through the same resampler as the microphone. A 16 kHz mono 16-bit WAV behaves as today.
  • A device that offers neither path is reported with its offered formats.

Runtime directory

  • One function names the runtime directory for the whole plugin. The model server socket, its pid file, the watcher sockets, the ssh control sockets, and the MLX model server socket all use it. The three separate copies of this logic are removed.
  • The directory is $XDG_RUNTIME_DIR/<plugin id> when XDG_RUNTIME_DIR is set and absolute. Otherwise it is a run directory inside the plugin state directory. The /tmp fallback is removed on every platform.
  • The plugin creates the directory with mode 0700. Before each use it verifies that the directory is owned by the current user and that group and others have no access. A directory that fails the check is refused with an error that names it. The plugin does not repair it silently.
  • Socket file names are short, so the path fits the macOS socket path limit of 104 bytes. The path length bound is platform-dependent: 104 on macOS, 108 on Linux.
  • When the model server socket path is too long, the model server is not used and doctor fails the check. The ssh control socket keeps its present rule: sharing is dropped and each call still works.

Local submit guard

  • On the local path, a delivery that asks to submit presses Enter only when Herdr's agent list names the latched pane. Otherwise the words are typed, Enter is withheld, and the delivery reports the same "agent gone" outcome that the remote path reports.
  • The same rule applies to the separate submit step that live typing uses.

Engine selection

  • The engine kind setting gains a second value for MLX. The default stays the bundled engine on every platform.
  • The whitespace collapse and the replacement table move to one place that runs after any engine. An engine returns raw text.
  • The Whisper-specific handling (prompt, no-speech gate, non-speech stripping, retry) stays inside the bundled engine.

MLX engine

  • The MLX engine is a separate model server process, not code linked into the binary. The crate keeps forbid(unsafe_code) and gains no FFI.
  • The MLX model server speaks the existing length-prefixed wire protocol without change: a sample count and 16-bit samples in, a status byte and length-prefixed text out. A connection that closes without a request is a readiness probe.
  • It binds its own socket in the runtime directory, with a different name from the bundled model server socket. It binds only after the model is loaded, so connectability is readiness.
  • It honours the existing idle period setting and exits when idle. It writes a pid file beside its socket, and the existing stop command stops it.
  • The plugin starts it lazily. With the MLX engine selected there is no in-process fallback. A dictation waits for readiness for a bounded time when it latches. If the server is not ready, the dictation fails before recording, as an unreachable saved machine does.
  • The server is a small program in the repository, run through uv with a lock file. uv is already on the fleet. This breaks the upstream "self-sufficient" rule, so the MLX engine is fork-only and is not offered upstream.
  • The default MLX model is a Parakeet build in MLX format, named by repository and pinned revision. Each file is verified against a digest recorded in the fork before the model is loaded. The implementer chooses the exact MLX library and model build, and records the choice and the reason in the measurement document.
  • The MLX server opens no network listener. Its only network use is the model download.

doctor

  • New checks on macOS: microphone permission, runtime directory ownership and mode, the backend the bundled engine reports, and socket path length.
  • The microphone permission check treats a brief recording of exact zeros as a probable denial. The remedy names the Privacy and Security microphone pane and the process to grant.
  • The implementer establishes by test which process macOS attributes the microphone to when Herdr starts the plugin (the terminal application or the Herdr server), and writes that into the remedy text and the README.
  • With the MLX engine selected, further checks cover uv, the locked environment, the model files and their digests, and server readiness.

Scripts and CI

  • The install script builds with the Metal feature on macOS and keeps its Linux behaviour.
  • The gate script and the release script run on macOS. GNU-only command forms are replaced with portable ones.
  • The GitHub workflow gains a macOS job that builds with the Metal feature and runs the tests. It stays in the GitHub workflow file so the change can go upstream.
  • The fork carries an upstream remote that points at GitHub with pushing disabled, and an origin remote on gen3.

Measurement

  • On one fleet Mac, both engines transcribe the same set of clips: the demo prompt in the repository, three short commands, and one dictation of 30 seconds or longer.
  • For each engine the document records cold start time, warm latency per clip, word error rate against a hand-written reference, and resident memory.
  • The document lands in the fork's docs directory. It states which engine the fleet should use.

Testing Decisions

A good test here checks external behaviour: what is typed, what is refused, what a file or directory looks like afterwards, what a socket answers. It does not assert internal call order or private state. Tests stay inline in each module, as upstream requires. No test needs a microphone or a running Herdr server.

  • Top seam: toggle --from-wav. A whole dictation is driven from a 48 kHz stereo WAV and from a 44.1 kHz mono WAV, with the Herdr socket pointed at a stub and the config, state, and runtime directories pointed at scratch directories. The test asserts what the stub was asked to type. Prior art: the upstream procedure for verifying without a microphone, and the existing --from-wav path.
  • Resampler, in the audio module. Pure tests over buffers: output length for a given input length and rate; a 1 kHz tone survives 48 kHz to 16 kHz within a small amplitude tolerance; a 10 kHz tone is attenuated; splitting the input into frames gives the same output as one buffer; a 16 kHz mono input is unchanged. Prior art: the existing silence detector and loudness tests in the audio module.
  • Runtime directory. Tests on the pure half that takes the environment and state directory as arguments: the chosen path for a set, unset, and relative XDG_RUNTIME_DIR; mode 0700 after creation; refusal of a directory with group or other access; a path over the platform bound is reported. Prior art: the existing watcher directory tests, which assert mode 0700 on the directory and its parent.
  • Local submit guard, in the sink. A stub Herdr socket answers the agent list with and without the latched pane. The test asserts that Enter is sent only in the first case and that the second reports the "agent gone" outcome. Prior art: the existing remote sink tests for the same rule.
  • Post-processing. A stub engine returns text with a newline and a replaceable phrase. The test asserts that the result is collapsed and replaced for any engine kind. Prior art: the existing replacement tests.
  • MLX wire protocol. The Rust client is tested against an in-process stub server on a socket pair: a transcript frame, an error frame, a readiness probe, and a server that never becomes ready. Prior art: the existing model server frame tests. The Python server has its own small tests for frame parsing; they load no model.
  • macOS CI job. Builds with the Metal feature and runs the test suite on a macOS runner.
  • Gate. scripts/check.sh passes on a fleet Mac with nothing skipped except the container step.
  • Manual acceptance, on one fleet Mac. A spoken dictation is typed into a Claude Code pane with each engine. toggle-send at a shell prompt types and does not submit. doctor passes, and fails with the correct remedy after microphone permission is revoked.

Out of Scope

  • Intel macOS, and any macOS release artifact, code signing, or notarisation.
  • Packaging the fork in dotfiles or Nix, and rolling it out to the fleet. That is a separate Workstation Management change after the measurement.
  • A Woodpecker lane for the fork on gen3. It needs an allowlist row under starbase ADR 0033. Until then the macOS CI job runs only where GitHub Actions run, and the local gate is the check on gen3.
  • The other findings of the security review: provenance verification in the install script, re-hashing a cached model, permissions on transcript state files, and pinning GitHub Actions by commit.
  • Opening pull requests against upstream. The commits are shaped for it, but each push to GitHub needs the operator's word.
  • Dictation from victor into a Mac pane. It waits on the victor SSH identity decision.
  • Whisper models on the MLX engine, and languages other than those the default MLX model supports.
  • Streaming transcription inside the MLX server. Live typing continues to send one chunk per request.

Further Notes

  • Source review: the secops and devops analysis of upstream v0.5.0 (commit 5bb42ca), captured in the vault as 2026-11-16-herdr-dictate-secops-devops-analysis.
  • Unverified assumptions that the implementer must confirm first, and report if false:
    1. The metal feature of the transcribe.cpp crate builds and runs on Apple Silicon. Nobody has built it in this work.
    2. Herdr's local socket API exposes the agent list that the Herdr CLI prints. If it does not, the local submit guard uses one CLI call, as machine selection already does.
    3. Herdr 0.9.0 or newer on the Macs accepts a plugin linked from a local checkout, and injects the same environment variables as on Linux.
    4. herdr plugin install may accept only GitHub shorthand. If so, hosts install the fork by linking a checkout.
  • A source-built binary in Herdr's plugin directory keeps its code hash until the next build. The microphone grant can therefore reset after each plugin update. doctor must make that state obvious.
  • Upstream releases about weekly. Merge upstream/main before the work starts and again before the measurement.
  • Suggested order: runtime directory, capture and resampler, local submit guard, Metal build and doctor, CI and scripts, then the MLX engine, then the measurement. The first five items are independent of MLX.
## Problem Statement herdr-dictate gives local speech-to-text dictation into the focused Herdr pane, but it runs on Linux only. The plugin manifest declares Linux as its one platform, and the microphone capture asks the device for 16 kHz mono directly, which CoreAudio devices do not offer. The four Apple Silicon Macs in the fleet (viper, viking, voyager, vega) therefore cannot dictate into a pane. Two more problems appear as soon as the plugin runs on macOS: - macOS has no `XDG_RUNTIME_DIR`. The model server socket and its pid file then fall back to a predictable directory under `/tmp` that is created without an ownership or mode check. Another local user can own that directory first, receive the raw audio, and return text that is typed into the pane. - On the local path, `toggle-send` presses Enter without a check that an agent holds the pane. At a shell prompt the transcript runs as a command. The remote path already makes this check. The operator also wants to know whether an MLX engine gives better latency or accuracy on Apple Silicon than the transcribe.cpp Metal backend that the crate already exposes as a feature. ## Solution A fork of herdr-dictate, at `git.gen3.dev/piersdd/herdr-dictate`, that runs on Apple Silicon macOS: - The microphone is opened at the format the device offers. A resampler converts the audio to 16 kHz mono before anything else sees it. - The default engine on macOS is the bundled transcribe.cpp engine, built with the Metal backend. It uses the same Parakeet model and the same settings as on Linux. - A second, opt-in engine runs the model with MLX in a separate model server process. The plugin starts and stops that process. The operator selects it with one setting. - All sockets live in one private runtime directory that the plugin creates with mode 0700 and verifies before use. There is no `/tmp` fallback on any platform. - `toggle-send` presses Enter on the local path only while an agent holds the pane, as the remote path does. - `doctor` reports the macOS-specific dependencies: microphone permission, the runtime directory, the Metal backend, and the MLX runtime when that engine is selected. - A measurement on one fleet Mac records latency and word errors for both engines. The result decides which engine the fleet uses. Linux behaviour does not change, except for the runtime directory fallback and the local submit check. ## User Stories 1. As a Mac operator, I want to press the dictate key and have my words typed into the focused pane, so that I can talk to an agent on macOS as a Linux user can. 2. As a Mac operator, I want the plugin to accept the microphone at its native sample rate and channel count, so that I do not have to configure an aggregate device or change system audio settings. 3. As a Mac operator, I want a built-in MacBook microphone, a USB microphone, and a Bluetooth headset each to work, so that the input device I have selected in macOS is the one that records. 4. As a Mac operator, I want the resampled audio to give the same transcript quality as a native 16 kHz recording, so that the port does not cost accuracy. 5. As a Mac operator, I want the model to run on the Apple GPU through Metal, so that a short command comes back in well under a second. 6. As a Mac operator, I want the Metal engine to fall back to the CPU when the GPU cannot be used, so that a dictation still completes. 7. As a Mac operator, I want live typing to work on macOS, so that words appear at each pause while I am still talking. 8. As a Mac operator, I want trailing silence to end a recording on macOS, so that I do not have to press the key a second time. 9. As a Mac operator, I want the plugin to install on macOS by a source build with the Metal backend, so that I need no prebuilt binary. 10. As a Mac operator, I want `doctor` to tell me that microphone permission is missing and to name the System Settings pane, so that a silent recording is not a mystery. 11. As a Mac operator, I want `doctor` to say which process macOS attributes the microphone to, so that I grant the permission to the right application. 12. As a Mac operator, I want a recording of pure digital silence to be reported as a probable permission denial, so that I do not raise the speech threshold to no effect. 13. As a Mac operator, I want to select the MLX engine with one setting, so that I can compare it with the Metal engine without a rebuild. 14. As a Mac operator, I want the plugin to start the MLX model server on the first dictation and stop it after the idle period, so that I run nothing by hand. 15. As a Mac operator, I want a dictation that selects the MLX engine to fail before recording starts when the MLX model server cannot start, so that I do not speak into a recording that can never be transcribed. 16. As a Mac operator, I want the replacement table and the whitespace collapse to apply to MLX transcripts, so that both engines give the same text rules and a dictated newline cannot submit a prompt. 17. As a Mac operator, I want the MLX model to be downloaded at a pinned revision and verified against known digests, so that the model the server loads is the model the fork names. 18. As a Mac operator, I want `doctor` to check the MLX runtime only when the MLX engine is selected, so that the default engine has no extra dependency. 19. As a Mac operator, I want `doctor` to name the engine, the model, and the backend that answered, so that I can confirm which engine a measurement used. 20. As a Mac operator, I want the status chip and `watch` output to work on macOS, so that my status line shows the dictation phase. 21. As a Mac operator, I want remote delivery to a saved machine to work from macOS, so that I can dictate on a laptop into a pane on voyager. 22. As a security reviewer, I want every socket and pid file in a directory that only my user can enter, so that another local user cannot read audio or inject text. 23. As a security reviewer, I want the plugin to refuse a runtime directory that it does not own or that group or others can enter, so that a directory planted before first use is not trusted. 24. As a security reviewer, I want `serve-stop` to signal only a pid read from the verified runtime directory, so that a planted pid file cannot make the plugin signal an arbitrary process. 25. As a security reviewer, I want `toggle-send` at a local shell prompt to type the words and not press Enter, so that a misheard phrase cannot run as a command. 26. As a security reviewer, I want the log to say when Enter was withheld because no agent held the pane, so that the behaviour is explainable. 27. As a security reviewer, I want the MLX model server to bind its socket only in the verified runtime directory and to accept only the existing wire protocol, so that it adds no network listener. 28. As a security reviewer, I want new dependencies to pass the existing licence and advisory gate, so that the fork keeps the upstream supply-chain posture. 29. As a Linux operator, I want capture on Linux to keep the direct 16 kHz path when the device offers it, so that the port changes nothing for me. 30. As a Linux operator, I want a device that offers no 16 kHz mono input to work through the resampler, so that the old "resampling is not implemented" error disappears. 31. As a developer, I want `toggle --from-wav` to accept a WAV at any sample rate and channel count, so that I can drive a whole macOS-shaped dictation without a microphone. 32. As a developer, I want the resampler to be pure functions over buffers, so that I can test it inline without a device. 33. As a developer, I want the gate script to pass on macOS, so that I can run the same checks on a Mac as CI runs. 34. As a developer, I want a macOS job in CI that builds with the Metal feature and runs the tests, so that the port cannot regress silently. 35. As a developer, I want the capture, runtime directory, and submit-guard changes as separate commits that do not depend on the MLX work, so that I can offer them to upstream as pull requests. 36. As the fleet owner, I want a written measurement of Metal against MLX on one fleet Mac, so that the engine choice rests on numbers. 37. As the fleet owner, I want the fork to track upstream by a read-only `upstream` remote, so that upstream fixes can be merged and nothing is pushed to GitHub by accident. ## Implementation Decisions **Platform** - The fork supports Linux as today and macOS on Apple Silicon. Intel macOS is not a target. - The plugin manifest declares both platforms. The plugin id stays unchanged, so the diff against upstream stays small. A host installs either upstream or the fork, never both. - On macOS the install step always compiles from source with the Metal feature. The fork publishes no macOS release artifact. **Capture and resampling** - The capture module remains the single platform boundary. It opens the default input device at 16 kHz mono when the device offers that format. Otherwise it opens the device's default input format. - A new streaming resampler in the audio module converts any input rate and channel count to 16 kHz mono 16-bit samples. It keeps state across frames, so frame boundaries add no clicks. It is band-limited, so a 48 kHz input does not alias. - The resampler comes from a pure-Rust crate with a permissive licence that passes the existing licence gate. No C dependency is added for it. - Everything after capture (silence detection, chunking, the meter, the engine) continues to see only 16 kHz mono samples. The 16 kHz target constant keeps its meaning. - The WAV source accepts any sample rate, any channel count, and 16-bit or float samples. It passes through the same resampler as the microphone. A 16 kHz mono 16-bit WAV behaves as today. - A device that offers neither path is reported with its offered formats. **Runtime directory** - One function names the runtime directory for the whole plugin. The model server socket, its pid file, the watcher sockets, the ssh control sockets, and the MLX model server socket all use it. The three separate copies of this logic are removed. - The directory is `$XDG_RUNTIME_DIR/<plugin id>` when `XDG_RUNTIME_DIR` is set and absolute. Otherwise it is a `run` directory inside the plugin state directory. The `/tmp` fallback is removed on every platform. - The plugin creates the directory with mode 0700. Before each use it verifies that the directory is owned by the current user and that group and others have no access. A directory that fails the check is refused with an error that names it. The plugin does not repair it silently. - Socket file names are short, so the path fits the macOS socket path limit of 104 bytes. The path length bound is platform-dependent: 104 on macOS, 108 on Linux. - When the model server socket path is too long, the model server is not used and `doctor` fails the check. The ssh control socket keeps its present rule: sharing is dropped and each call still works. **Local submit guard** - On the local path, a delivery that asks to submit presses Enter only when Herdr's agent list names the latched pane. Otherwise the words are typed, Enter is withheld, and the delivery reports the same "agent gone" outcome that the remote path reports. - The same rule applies to the separate submit step that live typing uses. **Engine selection** - The engine kind setting gains a second value for MLX. The default stays the bundled engine on every platform. - The whitespace collapse and the replacement table move to one place that runs after any engine. An engine returns raw text. - The Whisper-specific handling (prompt, no-speech gate, non-speech stripping, retry) stays inside the bundled engine. **MLX engine** - The MLX engine is a separate model server process, not code linked into the binary. The crate keeps `forbid(unsafe_code)` and gains no FFI. - The MLX model server speaks the existing length-prefixed wire protocol without change: a sample count and 16-bit samples in, a status byte and length-prefixed text out. A connection that closes without a request is a readiness probe. - It binds its own socket in the runtime directory, with a different name from the bundled model server socket. It binds only after the model is loaded, so connectability is readiness. - It honours the existing idle period setting and exits when idle. It writes a pid file beside its socket, and the existing stop command stops it. - The plugin starts it lazily. With the MLX engine selected there is no in-process fallback. A dictation waits for readiness for a bounded time when it latches. If the server is not ready, the dictation fails before recording, as an unreachable saved machine does. - The server is a small program in the repository, run through `uv` with a lock file. `uv` is already on the fleet. This breaks the upstream "self-sufficient" rule, so the MLX engine is fork-only and is not offered upstream. - The default MLX model is a Parakeet build in MLX format, named by repository and pinned revision. Each file is verified against a digest recorded in the fork before the model is loaded. The implementer chooses the exact MLX library and model build, and records the choice and the reason in the measurement document. - The MLX server opens no network listener. Its only network use is the model download. **doctor** - New checks on macOS: microphone permission, runtime directory ownership and mode, the backend the bundled engine reports, and socket path length. - The microphone permission check treats a brief recording of exact zeros as a probable denial. The remedy names the Privacy and Security microphone pane and the process to grant. - The implementer establishes by test which process macOS attributes the microphone to when Herdr starts the plugin (the terminal application or the Herdr server), and writes that into the remedy text and the README. - With the MLX engine selected, further checks cover `uv`, the locked environment, the model files and their digests, and server readiness. **Scripts and CI** - The install script builds with the Metal feature on macOS and keeps its Linux behaviour. - The gate script and the release script run on macOS. GNU-only command forms are replaced with portable ones. - The GitHub workflow gains a macOS job that builds with the Metal feature and runs the tests. It stays in the GitHub workflow file so the change can go upstream. - The fork carries an `upstream` remote that points at GitHub with pushing disabled, and an `origin` remote on gen3. **Measurement** - On one fleet Mac, both engines transcribe the same set of clips: the demo prompt in the repository, three short commands, and one dictation of 30 seconds or longer. - For each engine the document records cold start time, warm latency per clip, word error rate against a hand-written reference, and resident memory. - The document lands in the fork's docs directory. It states which engine the fleet should use. ## Testing Decisions A good test here checks external behaviour: what is typed, what is refused, what a file or directory looks like afterwards, what a socket answers. It does not assert internal call order or private state. Tests stay inline in each module, as upstream requires. No test needs a microphone or a running Herdr server. - **Top seam: `toggle --from-wav`.** A whole dictation is driven from a 48 kHz stereo WAV and from a 44.1 kHz mono WAV, with the Herdr socket pointed at a stub and the config, state, and runtime directories pointed at scratch directories. The test asserts what the stub was asked to type. Prior art: the upstream procedure for verifying without a microphone, and the existing `--from-wav` path. - **Resampler, in the audio module.** Pure tests over buffers: output length for a given input length and rate; a 1 kHz tone survives 48 kHz to 16 kHz within a small amplitude tolerance; a 10 kHz tone is attenuated; splitting the input into frames gives the same output as one buffer; a 16 kHz mono input is unchanged. Prior art: the existing silence detector and loudness tests in the audio module. - **Runtime directory.** Tests on the pure half that takes the environment and state directory as arguments: the chosen path for a set, unset, and relative `XDG_RUNTIME_DIR`; mode 0700 after creation; refusal of a directory with group or other access; a path over the platform bound is reported. Prior art: the existing watcher directory tests, which assert mode 0700 on the directory and its parent. - **Local submit guard, in the sink.** A stub Herdr socket answers the agent list with and without the latched pane. The test asserts that Enter is sent only in the first case and that the second reports the "agent gone" outcome. Prior art: the existing remote sink tests for the same rule. - **Post-processing.** A stub engine returns text with a newline and a replaceable phrase. The test asserts that the result is collapsed and replaced for any engine kind. Prior art: the existing replacement tests. - **MLX wire protocol.** The Rust client is tested against an in-process stub server on a socket pair: a transcript frame, an error frame, a readiness probe, and a server that never becomes ready. Prior art: the existing model server frame tests. The Python server has its own small tests for frame parsing; they load no model. - **macOS CI job.** Builds with the Metal feature and runs the test suite on a macOS runner. - **Gate.** `scripts/check.sh` passes on a fleet Mac with nothing skipped except the container step. - **Manual acceptance, on one fleet Mac.** A spoken dictation is typed into a Claude Code pane with each engine. `toggle-send` at a shell prompt types and does not submit. `doctor` passes, and fails with the correct remedy after microphone permission is revoked. ## Out of Scope - Intel macOS, and any macOS release artifact, code signing, or notarisation. - Packaging the fork in dotfiles or Nix, and rolling it out to the fleet. That is a separate Workstation Management change after the measurement. - A Woodpecker lane for the fork on gen3. It needs an allowlist row under starbase ADR 0033. Until then the macOS CI job runs only where GitHub Actions run, and the local gate is the check on gen3. - The other findings of the security review: provenance verification in the install script, re-hashing a cached model, permissions on transcript state files, and pinning GitHub Actions by commit. - Opening pull requests against upstream. The commits are shaped for it, but each push to GitHub needs the operator's word. - Dictation from victor into a Mac pane. It waits on the victor SSH identity decision. - Whisper models on the MLX engine, and languages other than those the default MLX model supports. - Streaming transcription inside the MLX server. Live typing continues to send one chunk per request. ## Further Notes - Source review: the secops and devops analysis of upstream v0.5.0 (commit `5bb42ca`), captured in the vault as `2026-11-16-herdr-dictate-secops-devops-analysis`. - Unverified assumptions that the implementer must confirm first, and report if false: 1. The `metal` feature of the transcribe.cpp crate builds and runs on Apple Silicon. Nobody has built it in this work. 2. Herdr's local socket API exposes the agent list that the Herdr CLI prints. If it does not, the local submit guard uses one CLI call, as machine selection already does. 3. Herdr 0.9.0 or newer on the Macs accepts a plugin linked from a local checkout, and injects the same environment variables as on Linux. 4. `herdr plugin install` may accept only GitHub shorthand. If so, hosts install the fork by linking a checkout. - A source-built binary in Herdr's plugin directory keeps its code hash until the next build. The microphone grant can therefore reset after each plugin update. `doctor` must make that state obvious. - Upstream releases about weekly. Merge `upstream/main` before the work starts and again before the measurement. - Suggested order: runtime directory, capture and resampler, local submit guard, Metal build and `doctor`, CI and scripts, then the MLX engine, then the measurement. The first five items are independent of MLX.
Author
Owner

Correction, 2026-11-16: the host platform assumption in this spec is false for the fleet.

herdr-dictate is a plugin for the legacy herdr TUI (manifest min_herdr_version = 0.9.0; it needs herdr plugin install, HERDR_SOCKET_PATH, the plugin action and pane system, and herdr machine list).

The fleet no longer runs that program. dotfiles removed it in #704 and #717. The Macs run herdr-core (hc, 0.1.x) and the Herdr app. Checked on voyager: no herdr on PATH, and hc --help lists no plugin command.

Consequences:

  • Assumption 3 under Further Notes is false as written. There is no Herdr 0.9 on the Macs to link the plugin into.
  • The capture, resampler, runtime-directory, engine and MLX work is still valid. It does not depend on the host.
  • The delivery layer (ipc, sink, machine, setup, indicator, the manifest) targets an API the fleet does not have. It needs either a port to the hc API (hc send, hc keys, hc ls, hc connect, hc schema) or a decision to reinstall legacy herdr.

Decision: port the delivery layer to herdr-core (hc), or bring legacy herdr 0.9 back on the Macs? Do not dispatch this issue until that is ruled.

**Correction, 2026-11-16: the host platform assumption in this spec is false for the fleet.** herdr-dictate is a plugin for the legacy `herdr` TUI (manifest `min_herdr_version = 0.9.0`; it needs `herdr plugin install`, `HERDR_SOCKET_PATH`, the plugin action and pane system, and `herdr machine list`). The fleet no longer runs that program. dotfiles removed it in #704 and #717. The Macs run herdr-core (`hc`, 0.1.x) and the Herdr app. Checked on voyager: no `herdr` on PATH, and `hc --help` lists no plugin command. Consequences: - Assumption 3 under Further Notes is false as written. There is no Herdr 0.9 on the Macs to link the plugin into. - The capture, resampler, runtime-directory, engine and MLX work is still valid. It does not depend on the host. - The delivery layer (`ipc`, `sink`, `machine`, `setup`, `indicator`, the manifest) targets an API the fleet does not have. It needs either a port to the `hc` API (`hc send`, `hc keys`, `hc ls`, `hc connect`, `hc schema`) or a decision to reinstall legacy herdr. **Decision:** port the delivery layer to herdr-core (`hc`), or bring legacy `herdr` 0.9 back on the Macs? Do not dispatch this issue until that is ruled.
Sign in to join this conversation.
No labels
ready-for-agent
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
piersdd/herdr-dictate#1
No description provided.