Skip to content

feat(apps): deliver proxy host lifecycle events to covered apps - #602

Closed
RentnerKev wants to merge 3 commits into
rentner/feat/all-proxy-hosts-scopefrom
rentner/feat/proxy-host-events
Closed

RentnerKev wants to merge 3 commits into
rentner/feat/all-proxy-hosts-scopefrom
rentner/feat/proxy-host-events

Conversation

@RentnerKev

Copy link
Copy Markdown
Member

Summary

PR 2 of 2 for #591, stacked on #601. Apps now receive durable host lifecycle events for changes from every platform write path, on the existing event stream with cursors.

Events (server/AppRuntime/host-events.server.ts)

  • Types: proxyHostCreated, proxyHostUpdated, proxyHostEnabled, proxyHostDisabled and proxyHostRemoved, with the platform host ID as resourceId.
  • recordProxyHostEventsInTransaction runs in the transaction that makes the change. For every installation whose published read or probe grant covers the host, it records one event per change, so an event exists exactly when the change commits.
  • proxyHostChange decides the event type from the stored settings before and after:
    • proxyHostUpdated when anything the listing reflects besides the enabled state changed;
    • otherwise the enabled transition;
    • otherwise nothing. A save that changes nothing, such as a repeated Docker discovery pass, records no event.

Write paths

  • Central helpers (create, update, delete): these cover the host form, Docker discovery, NPM, Portable and Zoraxy imports, certificate job creation and app-owned hosts.
  • Paths that write hosts directly:
    • enable and disable;
    • bulk enable, disable, certificate and access policy actions, inside their savepoint;
    • certificate job requests that disable the host;
    • certificate bindings;
    • certificate deletion, which detaches the certificate from its hosts;
    • trusted CA replacement, which changes the probe revision of every host that verifies against that CA.
  • Changes the listing does not reflect (tags, HTTP and cache settings) record no event.
  • An app that changes its own host through an owned-host operation still receives only its operation event (proxyHostChanged / proxyHostRemoved), never a second one for the same change.

Replay

  • A grant for all proxy hosts lets replay deliver the events of every host it reads or probes. Per-host grants keep matching exactly, so a revoked host's later events are not delivered.

Related issue

Closes #591 together with #601 (merge #601 first).
Refs RentnerProxy/app-monitoring#1

Type of change

  • Bug fix
  • New feature
  • Refactoring
  • Documentation
  • CI / tooling
  • Dependency update
  • Other

Testing

  • Web:
    • bun run typecheck and bun run lint are clean; the changed files are formatted.
    • Full test:ts on Windows: 2272 passed. The 41 failures are the tests/tooling Docker, release and backup script tests that fail the same way on main in this environment; CI runs them on Linux.
    • New host-events.test.ts: a save without a change records nothing; an enabled transition alone is reported as such; any other change, also with an enabled transition, is one update.
  • Database tests on PostgreSQL 18.7 in Kiri (104 passed across 9 suites):
    • proxy-hosts.db.test.ts: the host form records the following events, in this order, for an app with all proxy hosts: create, an unchanged save (no event), an update, disable, enable, a bulk disable, delete. An app with a per-host probe grant gets the changes after its grant, and an app without one gets nothing. Replay from a cursor continues after it without repeating an event.
    • trusted-cas.db.test.ts: replacing a CA records one update for the host that verifies against it, and none for the other host.
    • certificates.db.test.ts: deleting a certificate records one update for each detached proxy host.
    • certificate-jobs-worker.db.test.ts: binding an issued certificate records one update.
    • New host-events.db.test.ts: the acting installation is left out; read wins over probe with one event per change and app; a rolled-back change leaves no event.
    • host-operations.db.test.ts, proxy-host-listing.db.test.ts, authority.db.test.ts and certificate-jobs-creation.db.test.ts still pass.

Checklist

  • I tested the relevant functionality.
  • Existing tests pass. (CI pending)
  • I added or updated tests where appropriate.
  • This PR does not include secrets, credentials, production data, or private certificates/keys.
  • I updated documentation where necessary. Not needed.
  • I linked the relevant issue for a feature or fix, or explained why no issue is needed.

Breaking changes

None. Apps without a read or probe grant see no new events.

🤖 Generated with Claude Code

RentnerKev and others added 3 commits November 27, 2026 17:48
Every platform write path now records exactly one event per change for
each installation whose published read or probe grant covers the host,
in the transaction that makes the change: proxyHostCreated,
proxyHostUpdated, proxyHostEnabled, proxyHostDisabled and
proxyHostRemoved. A save that changes nothing records nothing.

The central create, update and delete helpers record the events, so
the host form, Docker discovery, imports, certificate job creation and
app-owned hosts are covered. The paths that write hosts directly do
too: enable and disable, bulk actions, certificate job requests and
bindings, certificate deletion and trusted CA replacement, which
changes the probe revision of the hosts that verify against it.

An app that changes its own host through an owned-host operation keeps
receiving only its operation event. Replay lets a grant for all proxy
hosts see the events of every host.

Refs #591

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Move the event log writes into event-log.server.ts and let the change
check take stored rows, so certificate and admin write paths do not
load the runtime authority or the proxy host mutation helpers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@RentnerKev

Copy link
Copy Markdown
Member Author

Replaced by #603: the same change as one commit, without the test UUID that Gitleaks flagged as a key in this branch's history.

@RentnerKev RentnerKev closed this Nov 27, 2026
@RentnerKev
RentnerKev deleted the rentner/feat/proxy-host-events branch November 27, 2026 19:00
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