Repository navigation
Conversation
This was referenced Oct 7, 2026
eli-r-ph
force-pushed
the
v1-capture-async-ai-lane
branch
from
October 7, 2026 03:56
d5eb0bc to
ae647de
Compare
eli-r-ph
force-pushed
the
v1-capture-invariant-tests
branch
from
October 7, 2026 03:56
6650520 to
7f7757a
Compare
eli-r-ph
force-pushed
the
v1-capture-invariant-tests
branch
4 times, most recently
from
October 7, 2026 04:54
7f7757a to
44df57f
Compare
This branch has not been deployed
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.
💡 Motivation and Context
posthog-go and posthog-rs found a set of capture invariants the hard way: a data race on enqueue during close, a pass-through hook that changed the wire, a size guard that refused events the endpoint accepts. This PR checks the Python stack against each one, and adds tests only where no existing test fails on the regression.
Changes
Tests only. No library code changes. Each invariant, and where it is covered:
before_sendleaves the wire unchanged (null option falls back to its legacy property, empty containers stay empty, nested maps survive)test_capture_invariants.py, sync and async, both lanestest_shutdown_waits_for_racing_enqueue_before_drainingnow runs on both lanes and asserts delivery and no live consumers. The async cross-thread admission test adds acapture_aicase that must start no AI workerssync_mode,capture_ai_immediateand the async queued lane, plus an over-guard casesync_modeand async tests now cover all four capture methods and assert the endpointTestLaneForkRebuild(both lanes,sync_mode)capture_ai_max_event_bytesvalidation is already tested💚 How did you test it?
Break-on-purpose, one mutation per invariant, each restored afterwards:
_closedunder the lock and puts outside it: both racing cases fail.capture_aiadmission case fails.One mutation was not caught:
_Lane.close()setting_closedwithout the lock. Shutdown still waits on that lock throughwait_for_sync_sends, so the race does not occur, and I did not add a test for it.📝 Checklist
If releasing new changes
sampo addto generate a changeset fileTests only; no changeset.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Written with Cursor (Claude Opus) under the direction of the assignee. Skills used:
writing-tests,writing-pr-descriptions.Agent calls worth review: