Skip to content

test(agents): drain relay renewal cleanup after setup failures - #149885

Merged
steipete merged 1 commit into
mainfrom
codex/native-hook-renewal-cleanup
Sep 16, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/native-hook-renewal-cleanup

Conversation

@steipete

@steipete steipete commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The native-hook renewal-expiry fixture can hide an initial locator polling failure. Its cleanup waits for a renewal-only deferred even when setup failed before renewal started, leaving the fixture pending until the outer test timeout.

User Impact

Test failures retain their original error and release fixture resources. Production relay behavior is unchanged.

Why This Change Was Made

Cleanup now releases the renewal barrier, unregisters the relay, and uses the existing clearNativeHookRelaysForTests owner to join admitted work. The bridge retains renewal work before the test observes its entry; unregister chains owned deletion and listener closure after that work. This removes the extra promise whose operation might never start, matching the preceding renewal-close fixture.

The expiry assertion, renewal entry/release barrier, locator polling, and deadlines remain unchanged.

Evidence

A controlled JavaScript proof executes the actual fixture and bridge drain owner with the registration facade, storage, HTTP, test-state, and test-runner effects mocked. The original fixture stays pending when publication lookup fails before renewal. The repaired fixture preserves the exact original error and completes cleanup. Both original and repaired successful-renewal controls pass, and the repaired drain joins renewal settlement before deletion and listener closure.

Scoped changed-file gates passed, including the affected agent test type graph, formatting, guards, all export scans, and targeted lint. Independent P0–P2 review found no actionable issues.

Hosted CI run 35073372705 passed for head 1063dc73757bdbabf52ee3697090ce5282e86923. Its changed-node job passed all 21 relay lifecycle cases, including the repaired expiry case in 880 ms, on tested merge 6beb0a7b05f02d2692dac5e6d4ee9b9b580e8b07.

No native SQLite or held-native scenario was run locally. This demonstrates the fixture cleanup defect; it does not establish that this path caused the timeout observed in CI run 35068857293.

@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS maintainer Maintainer-authored PR labels Sep 16, 2026
@steipete
steipete marked this pull request as ready for review September 16, 2026 08:21
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. labels Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 4:49 AM ET / 08:49 UTC (Revision 2).

ClawSweeper review

What this changes

The relay lifecycle test now releases its renewal barrier and drains registered cleanup work without waiting for a renewal that might never start.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused repair: current main retains the cleanup wait that can hang after setup failure. No actionable patch defects remain, and the maintainer-authored PR is protected from automatic closure.

Priority: P3
Reviewed head: 1063dc73757bdbabf52ee3697090ce5282e86923

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A narrow, maintainable cleanup repair with clear source justification and successful focused CI.
Proof confidence 🌊 off-meta tidepool Not applicable: The external-contributor proof gate does not apply to this maintainer-authored test repair; its controlled fixture probe is mocked evidence, supplemented by successful focused CI.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor proof gate does not apply to this maintainer-authored test repair; its controlled fixture probe is mocked evidence, supplemented by successful focused CI.
Evidence reviewed 7 items Verified introduced change: The pinned merge-base-to-head diff removes only the renewal-completion deferred and its cleanup wait. Locator polling, renewal entry, the expiry assertion, and existing cleanup calls remain.
Existing owner preserves cleanup ordering: Renewal is retained before its storage callback runs. Unregister chains owned deletion and listener closure after pending work; test cleanup repeatedly joins pending operations with Promise.allSettled. These production modules are identical between the reviewed head and fetched main.
Current-main necessity: Fetched main still awaits renewed.promise in finally, although locator polling can reject before relay.renew is called. The preceding renewal-close fixture already uses the cleanup sequence adopted here.
Findings None None.
Security None None.

How this fits together

Native-hook relays connect agent hook requests to OpenClaw and maintain a local listener plus a stored locator. This test checks renewal ordering and must finish relay cleanup before releasing its isolated test state.

flowchart TD
 A[Test setup] --> B[Publish relay locator]
 B --> C[Hold renewal at barrier]
 B --> D[Setup failure]
 C --> E[Release barrier and unregister]
 D --> E
 E --> F[Drain renewal and listener cleanup]
 F --> G[Release isolated test state]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests -6. Total -6 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 1 7 -6
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 1 7 -6

Review metrics

None.

Technical review

Best possible solution:

Keep teardown under the existing relay cleanup owner while preserving the renewal barrier and durable-expiry assertion.

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

Yes, from source: a locator-polling failure occurs before renewal starts, leaving the old finally block awaiting a deferred that cannot resolve. This review did not execute that failure path.

Is this the best way to solve the issue?

Yes. Reusing the existing drain removes the impossible wait without weakening assertions, extending deadlines, or adding another cleanup mechanism.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against bc8c9d43acba.

Labels

Label justifications:

  • P3: This improves test failure reporting and resource cleanup without changing production behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor proof gate does not apply to this maintainer-authored test repair; its controlled fixture probe is mocked evidence, supplemented by successful focused CI.

Evidence

What I checked:

  • Verified introduced change: The pinned merge-base-to-head diff removes only the renewal-completion deferred and its cleanup wait. Locator polling, renewal entry, the expiry assertion, and existing cleanup calls remain. (src/agents/harness/native-hook-relay.lifecycle.test.ts:873, 1063dc73757b)
  • Existing owner preserves cleanup ordering: Renewal is retained before its storage callback runs. Unregister chains owned deletion and listener closure after pending work; test cleanup repeatedly joins pending operations with Promise.allSettled. These production modules are identical between the reviewed head and fetched main. (src/agents/harness/native-hook-relay-bridge.ts:201, 1063dc73757b)
  • Current-main necessity: Fetched main still awaits renewed.promise in finally, although locator polling can reject before relay.renew is called. The preceding renewal-close fixture already uses the cleanup sequence adopted here. (src/agents/harness/native-hook-relay.lifecycle.test.ts:907, bc8c9d43acba)
  • Related merged groundwork and routing: The supplied GitHub context identifies refactor(hooks): await native relay persistence and drainage #144828 as merged. GitHub commit metadata connects steipete to the earlier lifecycle test and drainage work; that work supplies the cleanup owner rather than superseding this repair. Local blame encountered unavailable historical objects, so no blame-based introduction claim is made. (src/agents/harness/native-hook-relay.lifecycle.test.ts, f99d468c1ecc)
  • Validation and re-review continuity: GitHub confirms CI run 35073372705 and its checks-node-changed job succeeded for the reviewed head. The captured body reports all 21 lifecycle cases passing and describes a controlled mocked before/after failure probe. The prior completed review covered the same head and listed no findings. Detailed CI logs could not be retrieved through the allowed network route; tests were not executed during this read-only review. (1063dc73757b)
  • Release boundary: The lifecycle test file is absent at the supplied latest-release revision v2026.9.4; GitHub's contents endpoint returned 404. No released fix is claimed. (src/agents/harness/native-hook-relay.lifecycle.test.ts, 3a9d69db306c)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-16T08:29:22.704Z sha 1063dc7 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 6fcfa94 into main Sep 16, 2026
176 checks passed
@steipete
steipete deleted the codex/native-hook-renewal-cleanup branch September 16, 2026 08:51
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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