test(sim): deterministic proxy turn-lifecycle simulation harness - #1647
test(sim): deterministic proxy turn-lifecycle simulation harness#1647Komzpa wants to merge 14 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b90968755e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7413f657fc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Thanks for the fast turnaround on the first review round — all three of those fixes landed cleanly. The 08-08 re-review raised 3 new P2 threads that are still open and are the only remaining merge blockers (CI is green and the branch is mergeable):
Since #1 undermines the harness's own core promise (virtual-clock runs of the thread-goal path fail spuriously) and #2 can mask the very races the property test explores, these are worth fixing before merge. Given how quickly the first round was addressed, this looks close — happy to re-review once pushed. |
Extends the deterministic-simulation scheduler seam to the remaining anchored HTTP-bridge and websocket lifecycle owners so a simulation can own every task spawned by a proxy turn. Declares the clock and scheduler collaborators on the HTTP-bridge and websocket service protocols. Real clock/scheduler stay the defaults, so production behavior is unchanged.
Drives the idle-timeout and recovery-wait cancel/drain scenarios through the virtual scheduler instead of real asyncio timeouts, keeping the same behavioral assertions about queue revocation and completed-delivery dominance.
…aths The seeded schedule checker now dispatches each lifecycle event as a concurrent task with its own virtual wake-up deadline, so events sharing a deadline interleave at the await points inside the production release helpers instead of running in a fixed order. Release ownership goes through _release_websocket_response_create_ownership_for_cleanup and ProxyService._release_websocket_request_state_reservation, and the admission wait contends for a permit on a real WorkAdmissionController, which adds a liveness arm: a permit that is never handed back fails the checker. The canary plants the double-release-on-cancel bug in the cancel path itself. Local mutation checks confirm the checker also rejects a lost terminal claim, a dropped API-key reservation release, and a permit that is never released.
Drops the retry-circuit cooldown stub that had been added to the untouched real-clock completed-delivery test - it changes nothing there - and documents why the virtual-time idle-timeout scenario still needs it. Records the extra seam and verification tasks in the OpenSpec change.
Bridge and websocket lifecycle behavior lives in mixins whose methods the unit suite also drives with partial service doubles. Reading self._scheduler directly made four http-bridge idle-lease tests hang, so the seam now goes through scheduler_for()/clock_for(), which fall back to the real asyncio scheduler and real clock. Production wiring is unchanged. Collapses the admission-wait-timeout getattr in _get_work_admission onto one line so service.py stays inside the proxy architecture ratchet.
7413f65 to
3dccb14
Compare
|
The three 08-08 P2s all have real fixes on this head (injected clock through thread-goal budgeting, scheduler-owned bridge reader children, virtualized capacity-probe branches) — thanks. But the current head cannot be reviewed for merge:
Structural suggestion: this PR keeps getting invalidated because the production seam edits sit in the highest-churn files in the repo. Consider splitting it — land |
Adds a virtual-clock + controlled-scheduler simulation harness so the proxy turn lifecycle can be tested deterministically instead of via wall-clock sleeps and production flakes. This is the implementation-level leg of the codex-lb verification effort (alongside the TLA+ model #1621 and the timeout-invariant linter #1622).
Production unchanged: new
app/core/clock.py(Clock/Scheduler protocols with RealClock/RealScheduler as the defaults + tolerantscheduler_for/clock_foraccessors). Clock threaded through ProxyService/LoadBalancer/retry-circuit; scheduler through work-admission/bridge/websocket sleep+wait_for+task-spawn sites, so a simulation owns every task a turn spawns.Tests:
Runs in ~2s wall (33 tests), 3 consecutive green. openspec change
add-deterministic-proxy-simulationvalidates strictly. The 2 pre-existingtest_v1_responses_http_bridge_reconnects*failures also fail on plain origin/main (baseline, not introduced here).