Skip to content

fix(bin): withhold never-send values from dispatch resolver requests - #5744

Merged
kunchenguid merged 5 commits into
kunchenguid:mainfrom
zachlandes:fm/dispatch-router-privacy-check
Sep 27, 2026
Merged

kunchenguid merged 5 commits into
kunchenguid:mainfrom
zachlandes:fm/dispatch-router-privacy-check

Conversation

@zachlandes

@zachlandes zachlandes commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Intent

bin/fm-dispatch-resolve.sh sends a brief's task sections, the project name and the dispatch rules to the TypeSafe (Jev) endpoint to pick a crew profile. Before this change nothing checked that text, so a private value in a brief, such as a client name, left the machine whenever the resolver ran. This adds an optional never-send list, config/dispatch-never-send, that is checked against every string in the built request just before the POST. On a match the resolver sends nothing and takes the same "off" path as when no API key is set, so dispatch continues through the existing non-resolver intake.

The list is local and gitignored, and it ships with no entries. An absent file changes nothing, so the resolver stays on by default. Matching is literal and case-insensitive, and whitespace runs are collapsed so a value wrapped across lines still matches. Regex matching was deliberately left out, so a list entry cannot silently match more or less than it says. A list that exists but cannot be read also withholds the request, rather than sending unchecked text. The diagnostic names at most the list line number and never the value, so the check cannot itself leak what it protects.

The list is inherited into secondmate homes the same way as crew-dispatch.json, since those homes run the same resolver.

The check only covers this resolver's request. Other outbound paths are unchanged.

Verified with the new cases in tests/fm-dispatch-resolve.test.sh, and by running the real CLI in disposable homes against a local HTTPS recorder standing in for the endpoint. Every withheld run made zero requests.

Written with AI assistance and reviewed by the submitter.

What Changed

  • bin/fm-dispatch-resolve.sh now runs a check before its POST to Jev whenever the optional $FM_HOME/config/dispatch-never-send list exists. It checks every string in the built request against each non-blank, non-# line in the list. Matching is literal and case-insensitive, entries are trimmed, and any run of whitespace counts as one space. A match, or a list that is not a readable regular file, stops the request before it is sent. The resolver then takes its existing "off" path: one dispatch-resolve: off (...; nothing sent) line on stderr that names the list line number at most, nothing on stdout, no network or quota call, and exit 0. Firstmate then dispatches through its existing intake. When the file is absent, nothing changes.
  • bin/fm-config-inherit-lib.sh adds dispatch-never-send to the inheritable local config set, so secondmate homes withhold the same values.
  • docs/configuration.md documents the list's format, matching rules and fallback behavior. tests/fm-dispatch-resolve.test.sh adds tests for the check, including one that confirms an inherited list is enforced in a secondmate home.

Risk Assessment

✅ Low: The check is small, bounded and fails closed: never_send_check runs just before the only POST, after the request is built, and covers every string value in it. A match or an unusable list takes the documented off path (empty stdout, exit 0, no curl or quota call), which AGENTS.md already maps to the unchanged intake. Behavioral tests cover literal, wrapped, tab and NBSP spacing, project and rule matches, and secondmate inheritance.

Testing

The targeted test file tests/fm-dispatch-resolve.test.sh passed. I then ran the real router CLI in disposable lab homes, with real curl sent to a local HTTPS recorder standing in for the Jev endpoint. That covered nine scenarios: no-list and no-match baselines (request sent, status clear), and case-insensitive, wrapped, tab-spaced and project-name matches. It also covered a list path that fails closed as a directory or a broken symlink, the key-absent reference path, and a list inherited into a secondmate home through fm-config-push.sh. Every withheld run made zero requests and zero quota calls and never printed the listed value, and every scenario passed. The real TypeSafe API was not called because no TYPESAFE_API_KEY is available, and there is no UI surface, so the evidence is CLI transcripts.

  • Live validation: ✅ go - 8 of 8 scenarios driven live against the product
Scenario Result Live Evidence
No list: router sends the brief's task sections to Jev and resolves clear, unchanged from before ✅ pass live never-send-cli-transcript.txt S1: 1 request received with state.task.brief, status clear, 1 quota call
List with comment, blank and non-matching lines: request still sent and resolves clear ✅ pass live never-send-cli-transcript.txt S2: 1 request received, status clear
Adversarial: a listed 'example client ltd' vs a brief wrapping 'Example Client\nLtd' is withheld, with nothing sent ✅ pass live never-send-cli-transcript.txt S3: exit 0, empty stdout, 'off (brief text matches ... line 2; nothing sent)', 0 requests, 0 quota calls
Adversarial: a listed 'Before The Release' vs the brief's tab-spaced 'before the\trelease' is withheld ✅ pass live never-send-cli-transcript.txt S4: 0 requests, one off line
A list value matching the --project name (not the brief) is withheld ✅ pass live never-send-cli-transcript.txt S5: --project Orion-Private vs 'orion-private', 0 requests
Fail closed: a directory or a broken symlink at the list path stops the request instead of sending unchecked text ✅ pass live never-send-cli-transcript.txt S6/S7: 'is not a readable regular file; nothing sent', 0 requests, 0 quota calls
The withheld outcome matches the existing non-Jev off path (exit 0, one stderr off line, empty stdout), so firstmate uses its normal intake ✅ pass live never-send-cli-transcript.txt S8 (key-absent reference) compared with S3 to S7
A secondmate home inherits the list through fm-config-push.sh, and its router withholds the matching brief ✅ pass live never-send-secondmate-transcript.txt: 'dispatch-never-send: pushed', secondmate run withheld with 0 requests; control run without the list sent 1 request
Evidence: Live router CLI transcript for S1 to S8 (sent vs withheld, request/quota counts, stderr diagnostics)

Source: Live router CLI transcript for S1 to S8 (sent vs withheld, request/quota counts, stderr diagnostics)

# Live run of bin/fm-dispatch-resolve.sh (this branch) in a disposable lab FM_HOME minted by bin/fm-lab-home.sh.
# Real curl is redirected by CURL_HOME/.curlrc (connect-to) to a local HTTPS recorder standing in for api.typesafe.ai;
# quota-axi serves a fixture snapshot. 'requests received' is what reached the Jev endpoint.
# Brief (Captain's intent wraps 'Example Client' / 'Ltd' across a line and uses a tab before 'release'):
#   # Task
#   ## Captain's intent
#   Fix the pager for Example Client
#   Ltd before the	release.
#   
#   ## Firstmate spec
#   - Root cause is the off-by-one on line 40 of pager.sh.

$ FM_HOME=<lab> TYPESAFE_API_KEY=*** bin/fm-dispatch-resolve.sh brief.md --project pager   # S1 baseline: no list -> request sent to Jev, status clear
--- dispatch-never-send:
(absent)
exit=0
--- stdout:
dispatch-resolve:
  status: clear
  model: jev-local-recorder   latency_ms: 11   tokens: 1/1
  rule: rule_1 (A simple bug fix with a stated root cause.)   confidence: 0.92
  probabilities: rule_1=0.92 default=0.08
  note: rule matched
  candidate: claude:sonnet  provider=claude  scope=all_models  remaining=80%  spendPriority=0.5  runway=through_reset  -> eligible
  profile: --harness 'claude' --model 'sonnet' --effort 'high'
--- stderr:
--- requests received by the Jev endpoint: 1
{
  "project": "pager",
  "brief": "## Captain's intent\nFix the pager for Example Client\nLtd before the\trelease.\n\n## Firstmate spec\n- Root cause is the off-by-one on line 40 of pager.sh.\n"
}
--- quota-axi calls: 1

$ FM_HOME=<lab> TYPESAFE_API_KEY=*** bin/fm-dispatch-resolve.sh brief.md --project pager   # S2 list without a match -> still sent
--- dispatch-never-send:
-rw-r--r--@
# private values$
$
Unlisted-Value$
exit=0
--- stdout:
dispatch-resolve:
  status: clear
  model: jev-local-recorder   latency_ms: 11   tokens: 1/1
  rule: rule_1 (A simple bug fix with a stated root cause.)   confidence: 0.92
  probabilities: rule_1=0.92 default=0.08
  note: rule matched
  candidate: claude:sonnet  provider=claude  scope=all_models  remaining=80%  spendPriority=0.5  runway=through_reset  -> eligible
  profile: --harness 'claude' --model 'sonnet' --effort 'high'
--- stderr:
--- requests received by the Jev endpoint: 1
{
  "project": "pager",
  "brief": "## Captain's intent\nFix the pager for Example Client\nLtd before the\trelease.\n\n## Firstmate spec\n- Root cause is the off-by-one on line 40 of pager.sh.\n"
}
--- quota-axi calls: 1

$ FM_HOME=<lab> TYPESAFE_API_KEY=*** bin/fm-dispatch-resolve.sh brief.md --project pager   # S3 wrapped multi-word match, case-insensitive -> withheld
--- dispatch-never-send:
-rw-r--r--@
# Client names$
example   client ltd$
exit=0
--- stdout:
--- stderr:
dispatch-resolve: off (brief text matches <lab>/config/dispatch-never-send line 2; nothing sent)
--- requests received by the Jev endpoint: 0
--- quota-axi calls: 0

$ FM_HOME=<lab> TYPESAFE_API_KEY=*** bin/fm-dispatch-resolve.sh brief.md --project pager   # S4 tab-spaced match -> withheld
--- dispatch-never-send:
-rw-r--r--@
Before The Release$
exit=0
--- stdout:
--- stderr:
dispatch-resolve: off (brief text matches <lab>/config/dispatch-never-send line 1; nothing sent)
--- requests received by the Jev endpoint: 0
--- quota-axi calls: 0

$ FM_HOME=<lab> TYPESAFE_API_KEY=*** bin/fm-dispatch-resolve.sh brief.md --project Orion-Private   # S5 project-name match -> withheld
--- dispatch-never-send:
-rw-r--r--@
orion-private$
exit=0
--- stdout:
--- stderr:
dispatch-resolve: off (brief text matches <lab>/config/dispatch-never-send line 1; nothing sent)
--- requests received by the Jev endpoint: 0
--- quota-axi calls: 0

$ FM_HOME=<lab> TYPESAFE_API_KEY=*** bin/fm-dispatch-resolve.sh brief.md --project pager   # S6 list path is a directory -> withheld (fail closed)
--- dispatch-never-send:
drwxr-xr-x@
exit=0
--- stdout:
--- stderr:
dispatch-resolve: off (<lab>/config/dispatch-never-send is not a readable regular file; nothing sent)
--- requests received by the Jev endpoint: 0
--- quota-axi calls: 0

$ FM_HOME=<lab> TYPESAFE_API_KEY=*** bin/fm-dispatch-resolve.sh brief.md --project pager   # S7 list path is a broken symlink -> withheld (fail closed)
--- dispatch-never-send:
lrwxr-xr-x@
exit=0
--- stdout:
--- stderr:
dispatch-resolve: off (<lab>/config/dispatch-never-send is not a readable regular file; nothing sent)
--- requests received by the Jev endpoint: 0
--- quota-axi calls: 0

$ FM_HOME=<lab> bin/fm-dispatch-resolve.sh brief.md --project pager   # S8 reference: the existing key-absent off path (non-Jev intake)
exit=0
--- stdout:
--- stderr:
dispatch-resolve: off (TYPESAFE_API_KEY absent from the environment and <lab>/.env)
Evidence: Live secondmate inheritance transcript for S9 (fm-config-push.sh pushes dispatch-never-send; router in secondmate home withholds; control run sends)

Source: Live secondmate inheritance transcript for S9 (fm-config-push.sh pushes dispatch-never-send; router in secondmate home withholds; control run sends)

# S9: the primary lab home's config/dispatch-never-send reaches a secondmate lab home through the real bin/fm-config-push.sh,
# and the router run with FM_HOME=<secondmate> withholds the request. Same local HTTPS recorder stands in for api.typesafe.ai.
$ FM_HOME=<primary-lab> bin/fm-config-push.sh
WARNING: watcher still down (same stale episode; last beat: never, grace 300s) - full banner already printed this episode.
config-push: <primary-lab> -> live secondmate homes
secondmate sm1 (/private/var/folders/4n/_bv20k5d26dgrq1t5y4l69940000gn/T/fm-lab.9mXJiP-sm):
  crew-dispatch.json: pushed
  dispatch-never-send: pushed
  crew-harness: unchanged
  backlog-backend: unchanged
  backend: unchanged
  herdr-presentation-spaces: unchanged
  startup-memory-budget: unchanged
  trace-context: unchanged - session-scoped
  launch-env-allowlist: unchanged
  claude-permission-mode: unchanged
  lavish-axi-host: unchanged
  data/captain-shared.md: unchanged
CONFIG_REREAD: secondmate sm1: send failed: error: no-mistakes gate agent must not drive the fleet (NO_MISTAKES_GATE set)
(the reread-nudge send failure is the gate refusing to drive a fleet pane from inside this test run; the config push itself completed)

$ cat <secondmate>/config/dispatch-never-send
# Client names
Example Client Ltd

$ FM_HOME=<secondmate> TYPESAFE_API_KEY=*** bin/fm-dispatch-resolve.sh brief.md --project pager
exit=0
--- stdout:
--- stderr:
dispatch-resolve: off (brief text matches <secondmate>/config/dispatch-never-send line 2; nothing sent)
--- requests received by the Jev endpoint: 0
--- quota-axi calls: 0

# Control: remove the inherited list in the secondmate home -> the same brief is sent
  status: clear
--- requests received by the Jev endpoint: 1

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 8 of 8 scenarios driven live against the product
Scenario Result Live Evidence
No list: router sends the brief's task sections to Jev and resolves clear, unchanged from before ✅ pass live never-send-cli-transcript.txt S1: 1 request received with state.task.brief, status clear, 1 quota call
List with comment, blank and non-matching lines: request still sent and resolves clear ✅ pass live never-send-cli-transcript.txt S2: 1 request received, status clear
Adversarial: a listed 'example client ltd' vs a brief wrapping 'Example Client\nLtd' is withheld, with nothing sent ✅ pass live never-send-cli-transcript.txt S3: exit 0, empty stdout, 'off (brief text matches ... line 2; nothing sent)', 0 requests, 0 quota calls
Adversarial: a listed 'Before The Release' vs the brief's tab-spaced 'before the\trelease' is withheld ✅ pass live never-send-cli-transcript.txt S4: 0 requests, one off line
A list value matching the --project name (not the brief) is withheld ✅ pass live never-send-cli-transcript.txt S5: --project Orion-Private vs 'orion-private', 0 requests
Fail closed: a directory or a broken symlink at the list path stops the request instead of sending unchecked text ✅ pass live never-send-cli-transcript.txt S6/S7: 'is not a readable regular file; nothing sent', 0 requests, 0 quota calls
The withheld outcome matches the existing non-Jev off path (exit 0, one stderr off line, empty stdout), so firstmate uses its normal intake ✅ pass live never-send-cli-transcript.txt S8 (key-absent reference) compared with S3 to S7
A secondmate home inherits the list through fm-config-push.sh, and its router withholds the matching brief ✅ pass live never-send-secondmate-transcript.txt: 'dispatch-never-send: pushed', secondmate run withheld with 0 requests; control run without the list sent 1 request
  • bash tests/fm-dispatch-resolve.test.sh (existing plus new never-send cases, all passed)
  • Minted a disposable lab FM_HOME with bin/fm-lab-home.sh create, ran a local HTTPS recorder in place of api.typesafe.ai, and pointed real curl at it through CURL_HOME/.curlrc (connect-to + insecure). quota-axi served a fixture snapshot on the lab PATH
  • Live FM_HOME=&lt;lab&gt; TYPESAFE_API_KEY=dummy bin/fm-dispatch-resolve.sh brief.md --project ... for S1 (no list), S2 (list without a match), S3 (wrapped multi-word literal written in a different case), S4 (tab-spaced literal), S5 (project-name match), S6 (directory at the list path), S7 (broken symlink at the list path), and S8 (key-absent reference)
  • Live FM_HOME=&lt;primary-lab&gt; bin/fm-config-push.sh into a marked secondmate lab home, then the router run with FM_HOME=&lt;secondmate&gt;, plus a control run with the inherited list removed
  • Stopped the recorder and removed both lab homes (rm -rf)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.