Skip to content

Announce the two state changes that had no event - #17

Merged
fylorn merged 1 commit into
mainfrom
feat/push-state-events
Sep 15, 2026
Merged

fylorn merged 1 commit into
mainfrom
feat/push-state-events

Conversation

@fylorn

@fylorn fylorn commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

What

Adds two events to the bus: HealthChanged (a provider's breaker opened or closed) and ClientsChanged (a file on the client config face moved).

Why

Every event so far hangs off a request. These two pieces of state do not, so a desktop client displaying them had no way to learn about a change except to ask for the whole picture on a timer — /overview returns the entire configuration, and the clients list means re-scanning the user's home directory. On an idle gateway that is the same question asked over and over, with the caller diffing the answers to find out whether anything happened.

Notes

  • HealthChanged reports transitions only. Health::record_success / record_failure now return the state change, so what counts as one lives with the code that knows: a failure while already open is not a change; a failure after the cooldown expired is, because the interval in between really was "allowed to try again".
  • Recovery gets its own timer — it is the one transition no call triggers. The timer re-checks before it speaks, so a provider that recovered early (or tripped again) is not announced twice.
  • ClientsChanged is not ScanAlert: that one means "something suspicious appeared" and interrupts; this one means "those files moved" and prompts a quiet refresh.
  • Neither event is recorded to storage. Both describe what is true now; that table holds what happened.

Gates

cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace (61 binaries green), ./scripts/smoke.sh (46 passed, 0 failed).

🤖 Generated with Claude Code

Every event on the bus so far has hung off a request. Two pieces of
state that the UI displays do not, and the only way to observe them was
to ask for the whole picture again on a timer:

  · a provider's breaker opening or closing — reachable only by
    re-reading /overview, which returns the entire configuration
  · a file on the client config face changing — reachable only by
    re-scanning the user's home directory

A desktop client watching those had no choice but to poll. On an idle
gateway that is a question asked over and over about something nobody
touched, and the answer has to be diffed by the caller to find out
whether anything happened at all.

HealthChanged reports only transitions, never every failure — a caller
subscribing to it wants "what changed", not a second request stream.
The breaker now returns its state change from record_success and
record_failure, so the decision about what counts as a change lives
with the thing that knows: a failure while already open is not one,
and a failure after the cooldown ran out is, because the interval in
between really was "allowed to try again".

Recovery gets its own timer. It is the one transition no call triggers
— the cooldown simply runs out — and without it a client would show
"tripped" until some request happened to hit that provider again. The
timer re-checks before it speaks, so a provider that recovered early
(or tripped again) is not announced twice.

ClientsChanged is deliberately not ScanAlert. That one means "something
suspicious appeared" and is worth interrupting someone over; this one
means "those files moved" and is worth a quiet refresh. Editing
ANTHROPIC_BASE_URL back to its original value is not suspicious, but a
client that has adopted the gateway needs to notice.

Neither event is recorded to storage: both describe what is true now,
and that table holds what happened.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Thanks for the PR. One thing before review: this targets main, and it should target dev.

main is a release-only line — branch-protected, linear history, and every commit on it is a tagged release snapshot. Routine work lands on dev and reaches main with the next release. GitHub pre-filled main here because it is the default branch, so this is our defaults being unhelpful rather than anything you did wrong.

No need to close and reopen: click Edit next to the PR title and change the base branch to dev. The commits and the discussion carry over.

See CONTRIBUTING.md and CONTRIBUTING.md for the branch contract.

@fylorn
fylorn merged commit 1bee62b into main Sep 15, 2026
2 checks passed
@fylorn
fylorn deleted the feat/push-state-events branch September 15, 2026 09:34
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