feat(agents): add pull-wake runner health check and rename owner_user_id to owner_principal#4339
Open
KyleAMathews wants to merge 12 commits into
Open
feat(agents): add pull-wake runner health check and rename owner_user_id to owner_principal#4339KyleAMathews wants to merge 12 commits into
KyleAMathews wants to merge 12 commits into
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…dispatch-policy, server-utils, and electric-ax Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…URL form, callers convert keys to URLs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…migration, drop authorization fallback - Use principalKeyFromUrl for proper principal URL validation (rejects /principal/local-desktop) - Migration expires active claims and clears dispatch state before deleting runners - Desktop: don't use authorization header as principal source — return undefined and let server derive from ctx.principal.url - listRunners validates owner_principal query param Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…pal keys, complete desktop constant replacement Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
❌ 17 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a health check endpoint for pull-wake runners (
GET /_electric/runners/:id/health) and renamesowner_user_id→owner_principalacross the entire runners system. The health endpoint provides comprehensive diagnostics for debugging unreliable pull-wake dispatch, and the rename aligns the runners table with the principal identity model (URLs, not keys).Root Cause
The pull-wake dispatch system had no observability — when runners failed to receive or process wakes, there was no way to diagnose what was wrong. Additionally,
owner_user_idwas a misnomer since principals include agents, services, and system actors, not just users.Approach
Three-layer health diagnostics:
Client-side (
PullWakeRunner): Tracks 16 diagnostic fields — stream connection state, heartbeat results, claim outcomes (claimed/no_work/error), dispatch timestamps, reconnect counts. Reports these to the server via the existing heartbeat POST.Server-side storage: New
diagnosticsJSONB column on the runners table. The heartbeat handler persists client-reported diagnostics, making them available via Electric Shape sync for multi-device runner status.Health endpoint:
GET /_electric/runners/:id/healthaggregates runner state, client diagnostics, active claims, and dispatch stats. Derives a health status (healthy/degraded/unhealthy) from rules like lease expiry, stream connectivity, and heartbeat success.Principal rename:
/principal/user%3Aalice), not keys (user:alice)principalKeyFromUrl()— rejects invalid URLs at the API boundaryKey Invariants
owner_principalalways contains a canonical principal URL that passesprincipalKeyFromUrl()validationowner_principalagainstctx.principal.url(both URL form)Non-goals
owner_user_id— callers must updateVerification
Files changed
drizzle/0007_runner_diagnostics_and_principal.sqlagents-runtime/src/pull-wake-runner.tsgetHealth(), report diagnostics in heartbeat, extract claim helpersagents-server/src/db/schema.tsownerUserId→ownerPrincipal, adddiagnosticscolumnagents-server/src/electric-agents-types.tsRunnerHealthResponse/RunnerHealthStatus, type client diagnosticsagents-server/src/entity-registry.tsgetActiveClaimsForRunner/getDispatchStatsForRunneragents-server/src/routing/runners-router.tsagents-server/src/routing/dispatch-policy.tsowner_principal/ctx.principal.urlagents-server/src/utils/server-utils.tsowner_principal,diagnosticsagents-desktop/src/main.tselectric-ax/src/start.tsagents/src/server.tsownerPrincipalin registration🤖 Generated with Claude Code