feat(background_tasks): stamp executions with tenant, retry as original tenant (#371) [stack 8/11] - #392
Merged
Conversation
…nd retry as it (#371) TaskExecution gets a nullable, indexed tenant_id (NULL = beat / platform publish) stamped in on_task_publish from the message's tenant header or the publisher's current tenant, plus a (tenant_id, status, queued_at) index. Not MultiTenantMixin: beat publishes have no tenant. Retries re-publish under the original row's tenant (all_tenants() for a platform row) and copy tenant_id, so an operator who is a member of another org cannot trip the stamp mismatch. Admin screens stay platform-wide with a tenant column and filter. Claude-Session: https://claude.ai/code/session_01F8RiTBUJQnZmSq56qReZeV
Deploying simple-module-python with
|
| Latest commit: |
6d49da1
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://0770995b.simple-module-python.pages.dev |
| Branch Preview URL: | https://tenancy-08-background-tasks.simple-module-python.pages.dev |
…r default_tenant (review of #371) - prerun/postrun and the terminal signals pass the header's tenant into the upsert; never blank an existing stamp (platform messages stay NULL). - set_database_url takes default_tenant and builds EngineTenancy with it, so all_tenants() inserts in a worker land in the install's tenant (mirrors DatabaseState.default_tenant_id). Module startup and run_worker.py pass it. - Move the event-bus bridge to _signal_bus.py to keep signals.py under the 300-line cap (bind/unbind re-exported). Claude-Session: https://claude.ai/code/session_01F8RiTBUJQnZmSq56qReZeV
antosubash
added this pull request to stack #397
October 1, 2026 16:14
antosubash
marked this pull request as ready for review
October 1, 2026 16:16
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Closes #371. Stack 8/11 of the tenancy-adoption series (base: #391).
What
sync_db._build_engine,run_worker.py). They are verified and covered bytest_worker_tenancy.py, not redone.TaskExecutiongets a nullabletenant_id, stamped inon_task_publishfrom the message header, falling back tocurrent_tenant_id._publishruns undertenant_context(row.tenant_id), or underall_tenants()for a platform row. A platform admin who belongs to another org therefore doesn't hit the stamp mismatch._new_attemptcopiestenant_id, and bulk retry can be narrowed to one tenant.b5d3f08a6e17addstenant_idplus a(tenant_id, status, queued_at)index. The existing(status, queued_at)index is kept for the platform-wide screens.Tests
test_execution_tenancy.py: stamping, no blanking, the retry tenant (unit and endpoint, single and bulk), filters, and 403 for tenant roles.make test-jspasses.make lintandmake doctorare clean.Follow-ups
The "retry all" dialog text doesn't mention the tenant narrowing yet. The backend does honour it.
https://claude.ai/code/session_01F8RiTBUJQnZmSq56qReZeV