feat(agents-server): refactor routing for tenant library mode#4307
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4307 +/- ##
==========================================
- Coverage 58.84% 49.50% -9.34%
==========================================
Files 251 230 -21
Lines 24468 16524 -7944
Branches 6374 4869 -1505
==========================================
- Hits 14397 8181 -6216
+ Misses 10064 8334 -1730
- Partials 7 9 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
7943cfc to
2d05944
Compare
✅ Deploy Preview for electric-next ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
2d05944 to
bd8d8a8
Compare
bd8d8a8 to
f012030
Compare
f012030 to
8e8f2b1
Compare
icehaunter
added a commit
that referenced
this pull request
May 13, 2026
## Summary - Ports the pull-wake runner work onto the tenant-aware agents-server routing refactor. - Uses the current Durable Streams `v1/stream-meta/subscriptions/*` pull-wake API instead of restoring donor `/consumers` minting or monolithic server routing. - Keeps the routing-refactor branch as the source of truth for package organization, tenancy, and Durable Streams path mapping. - Adds follow-up fixes for Electron logging, desktop multi-instance dev startup, env override handling, and pull-wake/dev-auth test coverage. ## Work Done - Adds tenant-scoped pull-wake control-plane schema for runner registration, dispatch policy state, wake notifications, claims, offsets, and related public fields. - Extends server/runtime types with authenticated users, dispatch policies, runner rows, wake rows, claim rows, and public entity/type dispatch fields. - Adds focused `/_electric/runners` routes for registration, listing, heartbeat offset persistence, enable/disable, and claim handling with authenticated owner checks. - Implements dispatch-policy parsing and effective policy resolution for spawns, parent inheritance, and entity-type defaults. - Links entity main streams into Durable Streams runner/webhook subscriptions after spawn/fork and unlinks them on kill, using the routing adapter for all backend stream paths. - Extends `StreamClient` and the Durable Streams router to map subscription `wake_stream`, patterns, explicit streams, claim responses, ack requests, release requests, and response stream paths through the adapter. - Ports the runtime pull-wake runner loop for compact DS wake events, server-side claim enrichment, claim headers, claim-scoped write tokens, runner heartbeats, and done/ack transport. - Hardens callback-forward behavior for pull and webhook claims, including local claim responses, DS ack forwarding, entity running/idle state, stale conflict handling, and write-token lifecycle cleanup. - Ports the remaining UI/CLI integration needed for local asserted identity, auth-aware fetches, runner-backed local sessions, new session spawning, entity observe paths, sidebar session display, and the compose smoke stack. - Adds `ELECTRIC_DESKTOP_USER_DATA_DIR` and env-selected desktop server startup for multi-desktop local testing. - Makes the agents-server `start` script respect externally supplied dev env vars. - Adds tests for dev asserted auth, dispatch policy schema validation, entrypoint env parsing, and a mocked Horton pull-wake e2e. ## Verification - `pnpm -C packages/agents-runtime build` - `pnpm --filter @electric-ax/agents-server typecheck` - `pnpm --filter @electric-ax/agents-desktop typecheck` - `cd packages/agents-server && pnpm exec vitest run test/dev-asserted-auth.test.ts test/dispatch-policy-schema.test.ts test/entrypoint.test.ts test/horton-pull-wake-e2e.test.ts --reporter=dot` ## Stack - Stacked on #4307 (`feat(agents-server): refactor routing for tenant library mode`). --------- Co-authored-by: Kyle Mathews <mathews.kyle@gmail.com>
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
agents-serverfrom monolithic HTTP handling into a tenant-context-driven router architecture.globalRouter.fetch(request, tenantContext), while keeping an OSS standalone wrapper for local/server use.Work Done
TenantContext, tenant-aware runtime host wiring, per-tenant runtime/registry/stream clients, and tenant-scoped database schema updates.DurableStreamsRoutingAdapterplus the OSS path-prefixed single-tenant adapter for mapping public/runtime stream names to backend DS paths./v1/stream-meta/subscriptions/*, including path mapping, webhook URL rewriting, callback storage, claim/ack/release forwarding, and response mapping.server.tsand keeps routing code library-safe for external hosts that own tenancy and authentication.