Repository navigation
fix(server): run a delivery-loop wake under the agent's tenant (RIG-4167) - #1466
Merged
trunk-io[bot] merged 1 commit intoOct 2, 2026
Conversation
…167) The delivery consumer runs under the system role, so WakeAgent did too, and the agent_sessions row a fresh start records was stamped tenant_id ''. No tenant could see the woken session. WakeAgent now resolves the agent's tenant and runs the wake tenant-scoped. Co-authored-by: Matt Wilkinson <matt@rigel.build>
This was referenced Oct 2, 2026
Merged
|
Compass engineering docs preview: https://compass-server-rig-4167-wake.compass-eng-docs.pages.dev Deployed from |
rigel-mintaka
marked this pull request as ready for review
October 2, 2026 01:59
mattwilkinsonn
approved these changes
Oct 2, 2026
mattwilkinsonn
added this pull request to stack #1467
October 2, 2026 03:19
|
😎 Stack merged successfully - details. |
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.
Fixes RIG-4167. Stacked on #1465.
Problem
delivery.Consumer.Runruns understore.WithSystemRole. EveryWakeAgentit calls (mention wake, lost-session wake, owed wake on attach) inherited that context. The system role sets no tenant GUC, soRecordAgentSessionstampedagent_sessions.tenant_idwith''. No tenant's request path could read the woken session.Change
store.AccountTenantreadsaccounts.tenant_id.store.WithoutSystemRoleclears the system-role mark.lifecycleService.WakeAgentrunswakeCtxfirst. Under the system role it resolves the agent's tenant, then runs the wake asWithTenant(WithoutSystemRole(ctx)). If the tenant read fails, the wake is skipped and the error is logged.Tests
TestMentionBeforeRunnerEnrollsWakesOnAttachnow reads the woken session on the request path, under the bootstrap tenant. It passes 5/5 with-race. WithwakeCtxremoved it fails: "no session started for the owed agent after the Runner attached". The row exists but is stamped''.-race). sqlc drift is clean. Lint reports 0 issues.Known gap
Rows that earlier wakes already stamped
''(inagent_sessionsandsession_bindings) stay hidden from tenant-scoped reads. The next wake for those agents fresh-starts instead of resuming. A backfill needs a new migration, and compass-managed's #1375 currently holds0002. The backfill isUPDATE agent_sessions s SET tenant_id = a.tenant_id FROM accounts a WHERE s.agent_account_id = a.id AND s.tenant_id = '', plus the same for bindings. It is left for after #1375 lands, to avoid a migration-number collision.