Skip to content

Give forked backend workers distinct socket-owner identities - #7108

Merged
masenf merged 1 commit into
mainfrom
codex/prerelease-003-worker-token-identity
Sep 11, 2026
Merged

Give forked backend workers distinct socket-owner identities#7108
masenf merged 1 commit into
mainfrom
codex/prerelease-003-worker-token-identity

Conversation

@masenf

@masenf masenf commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

When an app is imported before a production server forks, every worker inherits the same token-manager instance ID. A worker receiving a backend-initiated delta then mistakes another worker's live socket record for its own stale record and drops the update.

Assign a fresh socket-owner identity at event-processor startup, after the fork and before events are processed. The change adds no per-event PID checks or allocations. Addresses prerelease finding 003; the defect is verified on the forked-worker path and is pre-existing.

Validation:

  • A new test forks the already-created app into two workers. Before the fix it fails because publishing the remote delta returns false; afterward both workers have distinct IDs and publish the expected payload to the owner's channel.
  • A separate probe using two forked processes and a temporary real Redis server delivered all six backend-initiated updates through EventNamespace.emit_update, with different parent/owner/sender identities. All probe processes were stopped.
  • App, token-manager, shared-state, and lifespan suites: 201 passed, 5 skipped. Ruff checks pass.

Reviewed the startup ordering, stable identity during event processing, and preservation of stale-local-socket rejection. This is independent of the production preload optimization in #7079, which makes the same lifecycle boundary particularly relevant.

Review in cubic

@masenf
masenf requested a review from a team as a code owner September 11, 2026 06:10
@greptile-apps

greptile-apps Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with startup ordering and cross-worker routing covered by a targeted regression test.

Summary

  • Adds a focused fork-based regression test covering distinct worker identities and remote delta publication.
  • Refactors token-manager identity generation into a reusable startup reset method.
  • Adds a user-facing bugfix news fragment.

Reviews (1) · Last reviewed commit: "fix(tokens): assign socket ownership ide..."

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Re-trigger cubic

@codspeed-hq

codspeed-hq Bot commented Sep 11, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 40 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing codex/prerelease-003-worker-token-identity (312c863) with main (074a818)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@masenf masenf added this to the 0.9.11 milestone Sep 11, 2026
@masenf
masenf merged commit 0c4ee52 into main Sep 11, 2026
114 checks passed
@masenf
masenf deleted the codex/prerelease-003-worker-token-identity branch September 11, 2026 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant