Skip to content

refactor(tests): share worker probes in agent tests - #167541

Merged
steipete merged 3 commits into
mainfrom
dbasync/dslpt1-1
Oct 9, 2026
Merged

steipete merged 3 commits into
mainfrom
dbasync/dslpt1-1

Conversation

@steipete

@steipete steipete commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Agent worker-boundary regressions repeat the same admission and command spy wiring in 35 files, making their domain scenarios harder to read.

User Impact

No user-visible change. Authority, freshness, FIFO, settlement, durability, and SDK contracts are unchanged.

Why This Change Was Made

A small infrastructure test probe now installs the existing synchronous admission and command forwarding adapters. The 47 migrated intercepts preserve their domain behavior, awaits, assertions, test names, and cleanup. Two mocked-module cases pass their explicitly imported native originals; nonmatching settlement adapters stay local.

Deslop

Collapsed 27 admission wrappers and 20 command wrappers. Main already consolidated three incognito revocation adapters into one owner; this PR preserves that consolidation and migrates that owner once. Removed the unused original-function aliases.

Category Added Removed Net
Production 0 0 0
Executable tests 593 775 -182
Test support 101 67 +34
Total 694 842 -148

The shared helper and its contract proof are included in these totals. No domain assertion or regression was deleted.

The command-probe contract test is intentionally retained: it independently protects direct Promise identity, AsyncLocalStorage continuity, the original scope receiver, explicit-original selection, and operation-level one-shot cardinality. The migrated T1.1 callers use persistent spies, so their domain cases do not cover the one-shot contract required by the later selected callers.

Integration

Initial main integration at ae64a98a4eb1 preserves the landed consolidation in #167554. The two worktree files now match that main commit exactly. The auth bootstrap scenarios keep the landed interceptBootstrap helper, which delegates its forwarding through the shared probe. This is test-only conflict resolution; production behavior, SQL, and assertions are unchanged.

A second integration at ec7c8bb9454b addresses the overlap with #167533: main's incognito actor helper keeps probe, while the shared worker import and its two admission calls use workerProbe. Both helpers and all assertions remain intact. This resolves ClawSweeper's integration prerequisite.

Released Plugin SDK check: no SDK exports, api.runtime contracts, documented subpaths, or production signatures change. The new probe is internal test support. SQL is neutral by construction because the production diff is empty; no SQL measurement was repeated at landing.

Evidence

  • Current-head CI run 37885435210 is green on 192b501ff17d8e6d86edbf4b2b93935d2cab60c9. No inherited-failure override is needed for this head. The earlier timer-count failure did not recur; no timer fix is claimed from that passing replay.
  • After the incognito integration: all 21 incognito tests passed with --maxWorkers=1 (461.86 s wrapper, 208.01 s Vitest); the selected agents-sessions typecheck passed in 25.1 s; formatting passed; Madge reported zero cycles; fresh isolated P2 autoreview was scoped-clean.
  • Integrated-head CI 37879973666 failed on two inherited checks: check-guards-architecture reports the same model-catalog cycle; checks-node-changed-4 reports subagent-registry-lifecycle.test.ts → keeps a required final scheduled after detached cleanup failures (expired during failure recovery), expected one fake timer but saw two at subagent-registry-lifecycle-cleanup.test-support.ts:559. The failing file, cleanup/controller fixtures, and production timer owners are unchanged. The failing retry cases register before the changed terminal-state cases, and the new probe module imports only Vitest at runtime and creates no timers. The precise extra-timer owner is not claimed. All other CI jobs completed without additional failures or cancellations, and security-fast passed. These failed conclusions are retained as historical evidence; the latest main integration and CI are reported separately.
  • After main integration: all 26 tests passed in shared-store-bootstrap.async.test.ts, registry-read.test.ts, and run-end.worker.test.ts with --maxWorkers=1. Wrapper wall time was 1,041.59 s, including cold compiled-worker preparation; Vitest projects took 329.02 s and 329.51 s. This is loaded-host proof, not a speedup claim.
  • Post-integration selected typechecks passed for agents-root, agents-other, agents-tools, state-logging, and agents-sessions (127.5 s total reported shard time). Formatting passed for the three resolved files. Fresh isolated P2 autoreview is scoped-clean with no actionable findings.
  • The first integration's Madge run reported one inherited cycle: src/agents/prepared-model-catalog-fingerprints.ts ↔ src/agents/prepared-model-catalog-worker.ts. Both files are byte-identical to integrated main ae64a98a4eb1; the PR changes no production files or graph configuration. The recent main CI run 37876418821 also has a failed architecture job, but its log download failed, so that run is not claimed as same-cycle proof.
  • 36 focused owner/consumer suites passed: 718 tests, 2,659 s wrapper wall time with --maxWorkers=1, on the initial 9afa39c base. Existing file-backed worker/lifecycle cases account for the cost; no domain case was added or removed.
  • After refreshing onto 50d7eb1, both overlapping suites (incognito sessions and live model switch) plus the shared-helper suite passed: 28 tests, 39.55 s Vitest / 111.44 s wrapper wall time. Unchanged proof was retained for the other suites.
  • Before the main integration, all 51 original callback bodies, async markers, spy cardinality, target modules, and 271 test registration/table signatures match the refreshed source. The new no-op observer on main remains unchanged.
  • Before the main integration, focused lint, selected test typechecks, formatting, database-worker and other ratchets passed; Madge reported zero cycles.
  • check-changed completed with inherited Knip unused-export failures only. All four listed production files are byte-identical to base 50d7eb1; this PR changes no production files or scan configuration.
  • CI run 37866588124 passed on head dae1bca. Logs confirm all 38 expected suites ran successfully. The archive E2E suite passed 19 tests in 14.41 s Vitest / 15.77 s runner time. Relevant file runs total 949.61 s across Node/Bun variants; the seven changed-test jobs used 1,656 s including setup and additional selected coverage. This CI proof resolved the local E2E artifact-isolation refusal and unadmitted Testbox queue.
Inherited Knip findings
  • src/agents/cli-runner/tool-authority.ts: bindCliQuestionAnswerAuthority
  • src/auto-reply/reply/session-event-handoff.ts: prepareSessionEventTargetForHost
  • src/config/sessions/session-accessor.sqlite-entry-cache-publication.ts: readSessionEntryCreationTransition
  • src/infra/heartbeat-events-filter.ts: RESTART_CONTINUATION_CONTEXT_PREFIX

Production scanning reports all four; full-tree scanning reports the last two. The script export scan passes.

Focused CI file-runner wall seconds
Suite Node Bun
src/agents/agent-create.workspace-worker.test.ts 43.38 —
src/agents/auth-profiles.sqlite-store.test.ts 10.05 —
src/agents/auth-profiles/oauth-personal.worker.test.ts — 13.9
src/agents/auth-profiles/shared-store-bootstrap.async.test.ts — 8.59
src/agents/embedded-agent-runner/run/attempt-execution-settle.test.ts 22.38 —
src/agents/embedded-agent-runner/run/attempt-transcript-recovery.test.ts 10.16 —
src/agents/embedded-agent-runner/run/lane-controller.writer-claim.test.ts 15.52 —
src/agents/embedded-agent-runner/transcript-rewrite.test.ts 63.67 —
src/agents/harness/native-session/binding-leases.worker.test.ts — 10.92
src/agents/live-model-switch.worker.test.ts 9.63 —
src/agents/mcp-oauth-store.test.ts 7.32 —
src/agents/openclaw-tools.sessions-send-child-coordination.test.ts 52.01 —
src/agents/sandbox/runtime-reservation.test.ts 22.37 —
src/agents/sessions/session-manager-async-message.test.ts — 8.13
src/agents/sessions/session-manager-branching.test.ts — 46.51
src/agents/sessions/session-manager-incognito.test.ts 18.96 —
src/agents/sessions/session-manager-static-notes.test.ts 24.4 —
src/agents/subagents/announce/subagent-announce.requester-settle-watch.test.ts 14.33 —
src/agents/subagents/completion/subagent-completion-admission.cancel-rollback.test.ts — 13.64
src/agents/subagents/completion/subagent-completion-admission.ended-hook.test.ts — 9.18
src/agents/subagents/completion/subagent-completion-admission.store.test.ts 19.82 —
src/agents/subagents/registry/subagent-announcement-delivery.worker.test.ts 67.23 —
src/agents/subagents/registry/subagent-registry-lifecycle.test.ts 29.9 —
src/agents/subagents/registry/subagent-registry-queued-recovery.test.ts — 21.62
src/agents/subagents/registry/subagent-registry-queued-registration.test.ts — 35.79
src/agents/subagents/registry/subagent-registry-requester-wake-pointer.worker.test.ts — 7.83
src/agents/subagents/registry/subagent-registry-sweeper-recovery.test.ts 23.6 —
src/agents/subagents/registry/subagent-registry-task-replacement.test.ts 41.75 —
src/agents/subagents/registry/subagent-registry-worker.test.ts — 35.94
src/agents/subagents/registry/subagent-registry.archive.e2e.test.ts 15.77 —
src/agents/subagents/registry/subagent-registry.completion-authority.test.ts — 21.36
src/agents/subagents/registry/subagent-registry.store-replaced.test.ts — 11.53
src/agents/tools/media-generate-background-retention.test.ts 40.51 —
src/agents/workspace-attestation.worker.test.ts 7.36 —
src/agents/workspace-state-read.worker.test.ts 21.94 —
src/agents/worktrees/registry-read.test.ts 80.41 —
src/agents/worktrees/run-end.worker.test.ts — 38.64
src/infra/sqlite-worker-owner-probe.test.ts 3.56 —

These are file-runner wall times including setup, not a before/after speedup claim.

@clawsweeper

clawsweeper Bot commented Oct 9, 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: XL labels Oct 9, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. labels Oct 9, 2026
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR shares database-worker interception helpers across agent regression tests while preserving their scenarios and assertions.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, mechanically sound test consolidation supported by worker-harness validation rather than shipped-entry-point proof.
Proof confidence 🦐 gold shrimp (3/6) Repository State identifies maintainer-authored test maintenance with no changed shipped behavior; recorded worker-suite runs and exact-head CI support preservation of the interception contracts.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes
Reason: Repeated interception wiring obscures meaningful worker regression scenarios. Consolidating those mechanics reduces maintenance without changing production behavior or weakening domain coverage.

Merge readiness

✅ Ready for maintainer review

This PR remains useful, distinct test maintenance. The integration concern is resolved, current-head CI passed, and no actionable patch defects remain.

Priority: P3
Reviewed head: 192b501ff17d8e6d86edbf4b2b93935d2cab60c9

Before merge

None.

Findings

None.

Agent review details

How this fits together

Agent regression tests exercise background database workers while injecting cancellation, ownership changes, and delayed acknowledgments. The shared probe forwards operations through the existing workers and leaves scenario decisions with each test.

flowchart TD
 A[Agent regression scenario] --> B[Shared test probe]
 B --> C[Admission interception]
 B --> D[Command interception]
 C --> E[Existing database worker]
 D --> E
 E --> F[Results and regression assertions]
Loading

Technical review

Best possible solution:

Share only interception mechanics, keeping domain-specific fault injection, assertions, and cleanup with their existing test owners.

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

Not applicable: this PR consolidates existing test wiring rather than repairing a reported product defect.

Is this the best way to solve the issue?

Yes: the narrow shared adapter removes repeated forwarding code while preserving existing callbacks, worker boundaries, and cleanup.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Introduced forwarding contracts: The introduced diff contains only tests and test support. Admission forwarding remains synchronous and retains attachments; command forwarding retains options, context, original scope, and direct Promise returns. Mocked-module consumers preserve explicitly selected native originals. (src/infra/sqlite-worker-owner-probe.test-support.ts:16, 192b501ff17d)
  • Independent probe contracts: The admission cases exercise real message ports and refusal decisions. Command cases protect Promise identity, asynchronous context, receiver identity, explicit-original selection, and operation-level one-shot interception; these are distinct forwarding invariants rather than duplicated domain scenarios. (src/infra/sqlite-worker-owner-probe.test.ts:12, 192b501ff17d)
  • Integration concern resolved: The incognito suite retains its existing actor probe and separately imports the worker probe as workerProbe. Both migrated admission calls use that distinct binding, preserving the landed actor helper and assertions. (src/agents/sessions/session-manager-incognito.test.ts:14, 192b501ff17d)
  • Still distinct from current main: Comparison with fetched main found no overlap between later main changes and the introduced paths; main does not contain the new shared probe. No merged fixing PR establishes that this consolidation is already implemented. (src/infra/sqlite-worker-owner-probe.test-support.ts, 4fe38b91ec98)
  • Current-head CI: GitHub independently confirms that https://github.com/openclaw/openclaw/actions/runs/37885435210 completed successfully on the exact reviewed head. Earlier failures remain historical observations; this passing run does not establish a timer-flake repair. (192b501ff17d)
  • Validation and review continuity: The complete supplied body, captured under sourceRevision aafb3283b0fea55f13008fc8337b9325b80a5f30422fe9d70901250682c4db20, records worker-suite and integration validation. The prior review covered this same head without findings or rank-up moves. No tests, builds, or bundled review helpers were executed during this read-only review. (192b501ff17d)

PR surface

Tests -148. Total -148 across 37 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 37 694 842 -148
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 37 694 842 -148

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is test-infrastructure maintenance without changed shipped behavior, configuration, or stored data.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (6 earlier review cycles)
  • reviewed 2026-10-09T00:52:38.378Z sha dae1bca :: needs maintainer review before merge. :: none
  • reviewed 2026-10-09T01:19:48.624Z sha dae1bca :: needs maintainer review before merge. :: none
  • reviewed 2026-10-09T01:39:25.846Z sha dae1bca :: needs maintainer review before merge. :: none
  • reviewed 2026-10-09T03:42:36.686Z sha e273123 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-09T04:09:23.018Z sha e273123 :: needs changes before merge. :: none
  • reviewed 2026-10-09T04:53:15.106Z sha 192b501 :: needs maintainer review before merge. :: none

Reviewed October 9, 2026, 1:13 AM ET / 05:13 UTC (Revision 7).

Preserve main's worktree interception helpers and auth bootstrap scenarios while routing the bootstrap forwarding through the shared probe. Production remains unchanged against main. Focused integration proof: 26 tests; five selected test typecheck lanes; formatting; clean P2 review. Madge reports an inherited model-catalog cycle in unchanged production files.
@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 9, 2026
Merge current main and keep its incognito actor probe separate from the shared worker admission probe. Preserve both helpers and all assertions. Focused proof: 21 incognito tests, selected session test types, formatting, zero Madge cycles, and clean P2 review.
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 9, 2026
@steipete
steipete merged commit 469457c into main Oct 9, 2026
133 checks passed
@steipete
steipete deleted the dbasync/dslpt1-1 branch October 9, 2026 05:32
@steipete

steipete commented Oct 9, 2026

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 P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL 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