Skip to content

feat(broker): gate broker advertisement on bundled fduty capability#58

Merged
ysyneu merged 1 commit into
mainfrom
feat/broker-fduty-capability-gate
Jun 8, 2026
Merged

feat(broker): gate broker advertisement on bundled fduty capability#58
ysyneu merged 1 commit into
mainfrom
feat/broker-fduty-capability-gate

Conversation

@ysyneu

@ysyneu ysyneu commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

What

The runner advertises broker=1 to safari only when both hold:

  1. the build supports the broker (BrokerSupported — Linux), and
  2. the bundled fduty is broker-capable (probed once via fduty version --jsonbroker_egress).

Why (rollout safety)

A broker-capable runner always advertised broker=1, which makes safari deliver the per-person app_key out-of-band (never in the bash env). But the runner does not refresh fduty on self-update, so a fleet runner can carry a stale, pre-broker fduty across a runner upgrade. That fduty can't read FLASHDUTY_CRED_FD → every authenticated call would fail.

Gating the advertisement on the bundled fduty's actual capability makes the rollout self-healing:

  • stale fduty → no advertisement → safari uses the legacy env-key path → old fduty keeps working;
  • once fduty updates → next reconnect advertises broker mode.

Works in zero-egress BYOC (no fduty refresh needed). Requires the companion cli change that adds broker_egress to fduty version --json (flashduty-cli#36).

How

  • environment/broker_capability.go: BrokerEgressEnabled() = BrokerSupported AND a cached one-time fduty version --json probe. Any probe failure (missing/old fduty, non-JSON, nonzero exit) → "not capable" → safe fallback.
  • ws/client.go: advertisement now gates on BrokerEgressEnabled().

Test

  • Unit: TestProbeFdutyBrokerEgress (capable / missing-field / false / legacy-plain-text / nonzero-exit) + missing-binary case.
  • e2e (real BYOC runner in a Linux container against a live backend):
    • new fduty → Safari logs broker=true → broker auth works (fduty whoami returns the real identity, zero app_key in container env);
    • legacy-fduty stub → Safari logs broker=false → env-key fallback still authenticates.

Follows flashduty-runner#56.

A runner built with broker support always advertised broker=1, which makes
safari deliver the per-person app_key out-of-band (never in the bash env). But
the runner does not refresh fduty on self-update, so a fleet runner can carry a
stale, pre-broker fduty across a runner upgrade. Such an fduty cannot read
FLASHDUTY_CRED_FD, so every authenticated call would fail.

Gate the advertisement on a one-time probe of the bundled fduty
(`fduty version --json` -> broker_egress). Now broker=1 is advertised only when
BrokerSupported AND the bundled fduty is broker-capable. A stale fduty keeps the
legacy env-key path and, once updated, the next reconnect advertises broker mode
— self-healing, and works in zero-egress BYOC where fduty cannot be refreshed.

Verified end-to-end: new fduty -> broker=true + broker auth works; legacy fduty
stub -> broker=false + env-key fallback still authenticates.
@ysyneu ysyneu merged commit aa1f09b into main Jun 8, 2026
10 checks passed
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