test(httpapi): fix WS writeback-origin flake + document #244 review notes (#245)#246
Conversation
…ew notes (#245) Flake fix per the #245 contract: TestFileEventsWebSocketWritebackMaterializationCarriesAgentWriteOrigin raced websocket.Dial returning (at HTTP upgrade) against the server registering its store subscription — a from=now subscriber misses a write landing in that window entirely (no catch-up), producing the ws-read deadline failure; interleaving produced the ordering failure. Fix: ping→pong barrier before the write (the pong is only written by the handler loop, which starts after the subscription is live — same pattern as the sibling from=now tests), then an order-tolerant scan for the materialization event. The origin assertion stays strict: the tolerance is about which frame carries the event, never about what origin it carries. Also lands the two ratified #244 review notes as code comments: - reconcileAckedDraftLocked: why the rename's deleted/created pair shares one revision while applyProviderUpsertLocked's relocate uses two. - sweep-drafts route: why sync:trigger (not fs:write) gates the sweep. Stress-verified: -count=20 green, -race -count=5 green. Closes #245 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
CodeAnt AI is reviewing your PR. |
|
Warning Review limit reached
More reviews will be available in 18 minutes and 28 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request adds explanatory comments regarding the use of the sync:trigger scope in server.go and the revision numbering convention in draft_reconcile.go. Additionally, it resolves a test flake in server_test.go by introducing a ping-pong synchronization step for WebSocket connections and implementing an order-tolerant event scanner. There are no review comments, and I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
CodeAnt AI finished reviewing your PR. |
Relayfile Eval ReviewRun: Passed: 4 | Needs human: 0 | Reviewable: 0 | Missing output: 0 | Failed: 0 | Skipped: 0 Human Review CasesNo reviewable human-review cases captured Relayfile output. |
Review verdict: APPROVE (bound to 26e838c)Reviewer: claude-mount-cleanup (channel verdict first per run rules; head re-verified).
Merge on full CI green + head still 26e838c. 🤖 Generated with Claude Code |
|
Fixed two validated issues beyond the PR diff:
Validated stale bot findings against the current checkout; the referenced SDK path no longer exists or was already fixed, and the mountfuse findings were already in the resolved state. Verification passed:
|
|
✅ pr-reviewer applied fixes — committed and pushed Fixed two validated issues beyond the PR diff:
Validated stale bot findings against the current checkout; the referenced SDK path no longer exists or was already fixed, and the mountfuse findings were already in the resolved state. Verification passed:
|
User description
Summary
Follow-up agreed in-run after #244's merge: relayfile#245's fix contract plus the two non-blocking #244 review notes as code comments.
Flake fix (#245)
TestFileEventsWebSocketWritebackMaterializationCarriesAgentWriteOriginracedwebsocket.Dialreturning (which happens at the HTTP upgrade,websocket.Accept) against the server registering its store subscription a few lines later. A write landing in that window is lost forever for afrom=nowsubscriber (no catch-up backfill) → thews-read deadlinesignature seen on #244's CI; interleaving produced the ordering signature seen on #243's CI.Fix, per the contract ("order-tolerant assertion, do NOT loosen the origin check"):
store.Subscribeis live. Same pattern the siblingfrom=nowtests already use (and it strengthens the test: asserts no backfill before pong).file.created /external/Writeback.mdframe instead of asserting the first frame.Ratified #244 review notes (comment-only)
reconcileAckedDraftLocked: revision convention — rename'sdeleted/createdpair shares ONE revision (single atomic transition of one logical file) vsapplyProviderUpsertLocked's relocate using two (genuinely two transitions); consumers are eventId-keyed.sync:triggeris deliberate (writeback-lifecycle family with/ack, matches operationally-available token scopes; dry-run default + name-shape + provider-linked/pending guards compensate the destructive surface).Verification
go test ./internal/httpapi/ -run TestFileEventsWebSocket -count=20green-race -count=5greeninternal/httpapi+internal/relayfilesuites green;go vetcleanCloses #245
🤖 Generated with Claude Code
CodeAnt-AI Description
Fix flaky writeback WebSocket test and clarify writeback rules
What Changed
agent_writesync:triggerpermissionImpact
✅ Fewer flaky WebSocket test failures✅ More reliable writeback event checks✅ Clearer permission and revision behavior for writeback flows💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.