Contain overlapping SaaS tenant runtime execution - #3
Merged
OneClickPostFactory merged 6 commits intoSep 6, 2026
Merged
OneClickPostFactory merged 6 commits into
OneClickPostFactory merged 6 commits into
Conversation
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.
Purpose
Contain D03 immediately while the larger immutable tenant/provider-context refactor is prepared.
The SaaS worker currently mutates process-global provider/model configuration inside withTenantRuntime. Cloudflare Worker isolates can interleave asynchronous requests, so overlapping cron or authenticated /tick drains could otherwise execute different tenant runtimes against the same mutable configuration and token-persistence callbacks.
This PR adds a bounded containment layer so only one SaaS job-drain execution can enter that mutable runtime at a time within a Worker isolate.
Changes
Important boundary: containment, not D03 completion
This does not make withTenantRuntime safe by design and does not claim immutable provider clients. The underlying shared mutation still exists.
The follow-up D03 change must remove tenant-specific mutation of shared config and global token-persistence callbacks, and instead pass immutable tenant/connection context directly into OpenAI and provider operations.
This containment removes the immediate overlap race before that larger refactor lands.
Preserved boundaries
Test intent
The new regression intentionally overlaps two logical tenant executions and asserts:
The full repository CI remains the required merge gate.
Dependency / merge order
This branch was created from the exact green head of PR #2:
a73d1d9
Because PR #2 has not yet merged into main, GitHub currently shows PR #3 as containing both the PR #2 release-safety commits and the D03 containment commits.
Merge PR #2 first. After PR #2 lands, PR #3 should reduce to only the containment delta before it is considered for merge.
Current containment head:
ee37777