Skip to content

test(discord): fix tail failure synchronization#140

Merged
steipete merged 2 commits into
mainfrom
fix/tail-update-race-0.11.7
Jul 18, 2026
Merged

test(discord): fix tail failure synchronization#140
steipete merged 2 commits into
mainfrom
fix/tail-update-race-0.11.7

Conversation

@steipete

@steipete steipete commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Separate tail cancellation from the five-second test deadline in both affected message-update failure tests.
  • Remove race-sensitive false failures that block the v0.11.7 release gate.

Root cause

OnTailFailure closes failureReported before canceling the tail context. Two tests incorrectly used that same context as their five-second assertion deadline. If the gateway goroutine was scheduled after both channels became ready, Go could select ctx.Done() even though the failure notification already happened. The production recorder and reporter ordering is correct; the tests conflated successful tail cancellation with a test timeout.

Proof

go test -race ./internal/discord -run '^TestTailMessageUpdateFailureUsesRefetchedMetadata$' -count=100
ok github.com/openclaw/discrawl/internal/discord 305.233s

go test -race ./internal/discord -run '^TestTailMessageUpdateRejectsConflictingRefetchIdentity$' -count=100
ok github.com/openclaw/discrawl/internal/discord 302.697s

Full local gate:

  • Tests, full race suite, build, and real CLI smoke: pass; filtered coverage 85.3%.
  • golangci-lint, vet, staticcheck, deadcode, gofumpt, and gosec: pass.
  • Module verify/tidy and govulncheck: pass; zero called vulnerabilities.
  • Six-target GoReleaser snapshot, gitleaks history/tree, and shell syntax: pass.
  • Docker build and version/help smoke: pass.
  • AutoReview: clean, score 0.98.

Changelog omitted: test synchronization only; no shipped behavior change.

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal priority bug or improvement with limited blast radius. labels Jul 18, 2026
@clawsweeper

clawsweeper Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 17, 2026, 10:33 PM ET / July 18, 2026, 02:33 UTC.

Summary
The PR separates tail cancellation from the five-second assertion deadline in two Discord tail-failure tests to remove a race-sensitive false timeout.

Reproducibility: no. deterministic current-main reproduction was independently established in this read-only review. The PR body gives a credible scheduler-dependent path and repeated post-fix race runs, so the timing issue is source-reproducible but inherently nondeterministic.

Review metrics: 2 noteworthy metrics.

  • Test surface: 1 file changed; 16 added, 12 removed. The patch is narrowly confined to synchronization in two existing Discord tests.
  • Race repetition: 2 targeted tests run 100 times each under -race. This directly increases confidence in the stated flaky timing path.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Next step before merge

  • [P2] No mechanical repair is indicated; an explicit maintainer review is required because this collaborator-authored PR must remain open under the conservative cleanup policy.

Security
Cleared: The supplied diff changes only test context wiring and introduces no dependency, workflow, secret, permission, or executable supply-chain surface.

Review details

Best possible solution:

Merge the focused context-separation test fix once maintainer review confirms the intended tail-failure ordering and the remaining required checks finish successfully.

Do we have a high-confidence way to reproduce the issue?

No deterministic current-main reproduction was independently established in this read-only review. The PR body gives a credible scheduler-dependent path and repeated post-fix race runs, so the timing issue is source-reproducible but inherently nondeterministic.

Is this the best way to solve the issue?

Yes. Separating the assertion deadline from the intentionally cancelled tail context is the narrowest maintainable way to prevent a successful cancellation from being selected as a test timeout.

AGENTS.md: unclear because the file could not be read completely.

Codex review notes: model internal, reasoning high; reviewed against 1d1b8a0a61ac.

Label changes

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded Discord test-stability improvement associated with a release gate, without evidence of a current user-facing outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR includes terminal evidence of both affected tests passing 100 times under the race detector after the change; this is appropriate real behavior proof for a non-visual Go test synchronization fix.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR includes terminal evidence of both affected tests passing 100 times under the race detector after the change; this is appropriate real behavior proof for a non-visual Go test synchronization fix.
Evidence reviewed

What I checked:

  • Focused test synchronization change: The supplied diff changes only internal/discord/client_test.go, introducing a deadline-owned testCtx and a separately cancellable tailCtx in both affected test cases so cancellation cannot race with the assertion timeout. (internal/discord/client_test.go:2547, 2ae98a5e5307)
  • Repeated race validation: The PR body reports each affected test passing 100 times under go test -race, directly exercising the timing-sensitive paths after the synchronization change. (internal/discord/client_test.go:2547, 2ae98a5e5307)
  • Current review cycle: The prior completed ClawSweeper cycle reported no findings; the current head adds the explicit context separation described in the PR and no unresolved prior blocker is present in the supplied review context. (internal/discord/client_test.go:2547, 2ae98a5e5307)
  • Collaborator safeguard: The GitHub context identifies the author as COLLABORATOR; this cleanup workflow keeps collaborator-authored pull requests open for explicit maintainer judgment. (2ae98a5e5307)

Likely related people:

  • steipete: Authored both commits in this PR, including the follow-up that explicitly separates the test deadline from tail cancellation. (role: recent area contributor; confidence: medium; commits: 851579f9e2b9, 2ae98a5e5307; files: internal/discord/client_test.go)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (1 earlier review cycle)
  • reviewed 2026-07-18T02:20:23.400Z sha 851579f :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jul 18, 2026
@steipete
steipete merged commit 15af971 into main Jul 18, 2026
10 checks passed
@steipete
steipete deleted the fix/tail-update-race-0.11.7 branch July 18, 2026 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant