Skip to content

Make node auto-approve tests deterministic #460

Closed

Description

@shanselman

PR #457's auto-approval behavior is now covered well, but a few negative/dedup checks still use short Task.Delay(...) waits to prove something did not happen, and one path depends on the production 1s reconnect delay.

Follow-up:

  • Replace timing-based negative assertions with deterministic completion/synchronization signals.
  • Consider injecting a delay/time provider into GatewayConnectionManager so tests can set the post-approve reconnect delay to zero.
  • Preserve coverage for: other-node requests are ignored, missing approval scope is ignored, duplicate request IDs are not approved twice, and node-side skipped attempts do not suppress later operator-side approval.

Context: identified during review of #457.

Activity

  1. added a commit that references this issue on May 19, 2026
    f505ab1
  2. github-actions commented on May 19, 2026

    @github-actions
  3. added
    enhancement
    on May 19, 2026
  4. clawsweeper commented on May 24, 2026

    @clawsweeper

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve.

    Latest ClawSweeper review: 2026-05-24 07:49 UTC / May 24, 2026, 3:49 AM ET.

    Workflow note: Future ClawSweeper reviews update this same comment in place.

    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.

    Summary
    Keep open: current main still has fixed-delay assertions in NodePairAutoApproveTests and no deterministic completion hook or injectable post-approve delay, while the linked Repo Assist patch was closed unmerged because it mixed test cleanup with runtime operator-side auto-approve behavior.

    Reproducibility: yes. from source inspection, not by running tests: current main still contains the fixed Task.Delay(200) waits in NodePairAutoApproveTests and the hard-coded 1 second post-approve delay in GatewayConnectionManager.

    Next step
    A narrow repair is clear if it is limited to current-main test synchronization and does not revive the removed operator-side auto-approve path.

    Review details

    Best possible solution:

    Land a fresh focused test-determinism PR on current main, replacing only the existing node-side test waits with deterministic signals and delay injection while keeping operator-side auto-approve out unless separately approved.

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

    Yes from source inspection, not by running tests: current main still contains the fixed Task.Delay(200) waits in NodePairAutoApproveTests and the hard-coded 1 second post-approve delay in GatewayConnectionManager.

    Is this the best way to solve the issue?

    Yes for a narrow repair: deterministic completion synchronization plus an injectable test delay is the maintainable path, but #464 is not suitable as-is because it also depended on operator-side runtime code that was later removed.

    Label changes:

    • add P3: This is low-risk test determinism cleanup with no direct production user impact.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.
    • add clawsweeper:queueable-fix: Current issue advisory state selects this label.
    • add clawsweeper:fix-shape-clear: Current issue advisory state selects this label.

    Label justifications:

    • P3: This is low-risk test determinism cleanup with no direct production user impact.

    Acceptance criteria:

    • ./build.ps1
    • dotnet test ./tests/OpenClaw.Connection.Tests/OpenClaw.Connection.Tests.csproj
    • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore
    • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore

    What I checked:

    Likely related people:

    • shanselman: Blame attributes the current NodePairAutoApproveTests timing waits and GatewayConnectionManager constructor baseline to Scott Hanselman, and commit 45dccec intentionally removed the operator-side auto-approve path. (role: recent area contributor; confidence: high; commits: c499c294b764, 45dccec60c51, ef6ac8acbab2; files: tests/OpenClaw.Connection.Tests/NodePairAutoApproveTests.cs, src/OpenClaw.Connection/GatewayConnectionManager.cs)
    • ranjeshj: Commit 7747e60 introduced the merged auto-approve refinements and post-approval reconnect flow that the tests cover. (role: feature contributor; confidence: medium; commits: 7747e6075052; files: src/OpenClaw.Connection/GatewayConnectionManager.cs, tests/OpenClaw.Connection.Tests/NodePairAutoApproveTests.cs)

    Remaining risk / open question:

    • Copying the closed Repo Assist branch as-is would reintroduce operator-side NodePairListUpdated auto-approve behavior that was removed for a WSL setup race.
    • The repair should preserve the production 1 second post-approve delay by default and use any delay injection only for tests.

    Codex review notes: model gpt-5.5, reasoning high; reviewed against ef6ac8acbab2.

  5. added
    P3
    issue-rating: 🦞 diamond lobster
    clawsweeper:source-repro
    clawsweeper:queueable-fix
    clawsweeper:fix-shape-clear
    on May 24, 2026
  6. added a commit that references this issue on May 26, 2026
    84cc251
  7. github-actions commented on May 26, 2026

    @github-actions
  8. github-actions commented on May 27, 2026

    @github-actions
    Contributor

    🤖 This is an automated response from Repo Assist.

    Good news: the deterministic fix appears to be already in master (commit 2ca3457). The test file now uses WaitForApprovalCallAsync() and WaitForApprovalCompleteAsync() deterministic helpers, and GatewayConnectionManager has the _reconnectDelay injection — all the changes described in the issue. All 256 connection tests pass.

    This issue looks safe to close unless there's something else outstanding.

    Generated by 🌈 Repo Assist, see workflow run.

    Generated by 🌈 Repo Assist, see workflow run. Learn more.

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/repo-assist.md@97143ac59cb3a13ef2a77581f929f06719c7402a
    
  9. ranjeshj commented on Jun 2, 2026

    @ranjeshj
    Contributor

    Confirmed this is already resolved on current master. The node auto-approve tests now use deterministic synchronization helpers instead of short negative Task.Delay waits, and GatewayConnectionManager has injectable reconnect delay while preserving the production default. Targeted verification passed: dotnet test .\tests\OpenClaw.Connection.Tests\OpenClaw.Connection.Tests.csproj --filter NodePairAutoApproveTests (4 passed, 0 failed). Closing as already fixed.

  10. ranjeshj commented on Jun 2, 2026

    @ranjeshj
    Contributor

    Closing as already fixed on current master.

  11. locked as resolved and limited conversation to collaborators on Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3clawsweeper:fix-shape-clearclawsweeper:queueable-fixclawsweeper:source-reproenhancementissue-rating: 🦞 diamond lobster

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions