Skip to content

refactor(agents): move recovery tests to owners - #123022

Merged
steipete merged 4 commits into
mainfrom
test/audit-incomplete-turn-runner-mirror
Aug 13, 2026
Merged

steipete merged 4 commits into
mainfrom
test/audit-incomplete-turn-runner-mirror

Conversation

@steipete

@steipete steipete commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Resolves a test-ownership problem where three incomplete-turn suites exercised a 489-line copied run loop instead of the production recovery, terminal-resolution, and assistant-failure owners. The mirror manually implemented retries, prompt mutation, provider API selection, failover checks, and terminal results, so it could pass when production behavior changed and required lockstep test-only repairs.

Exact-head CI also exposed two unrelated main test-infrastructure failures while landing this cleanup: a Discord send test exceeded the max-lines limit, and Discord draft suites could freeze for 120 seconds because their fake clock also owned the status-reaction terminal hold.

Why This Change Was Made

The empty-response, reasoning-recovery, and silent-reply synthetic suites are deleted. Their unique contracts now run directly against typed production owners:

  • recovery policy tables cover provider/API eligibility, model-visible continuation prompts, side-effect gates, and intentional silence;
  • terminal resolution covers required empty retries, exact NO_REPLY, reply-optional side effects, reasoning exhaustion with terminal presentation, missing-assistant persistence, and settled-tool finalization requests;
  • assistant failure covers replay-safe reasoning-only error retry before failover;
  • compaction timeout metadata stays at its direct owner.

The old split-suite CI rows are removed, and the now-internal model resolver mock is no longer exported from the remaining temporary harness support.

To repair the red main lint gate without a suppression, Discord send coverage is physically split at an existing top-level boundary while retaining one Vitest module and one broad mock lifecycle: thread/admin coverage stays in the discovered test file, and guild assets, stickers, polls, and retry cases live in a registered test-support module imported by it. This avoids the shared-worker mock collision that occurred when the sections were separate test files.

The final Discord no-output timeout had a different owner. Draft-stream tests used a context that enabled status reactions, while their delay helper froze the global clock. They were therefore awaiting a reaction terminal hold that the test did not own. Draft suites now use a draft-specific context with status reactions disabled; reaction-specific tests keep explicit external clock control. Three duplicate shared-controller assertions were removed, and tracked-target coverage now retargets to a genuinely different message.

User Impact

No user-visible behavior change. Recovery policy tests now fail when the real owner changes, not when a copied loop drifts. Discord draft tests no longer depend on an unrelated reaction timer lifecycle, and retained reaction tests protect Discord-owned target binding rather than re-proving generic controller timing.

Evidence

  • 444 focused owner, routing, session-state, normalization, and remaining incomplete-turn tests passed.
  • Real Gateway QA scenarios passed: empty-response retry budget exhaustion, Anthropic reasoning-error recovery after a replay-safe read, and one-write/one-finalization cron recovery.
  • The registered Discord send test passed 42/42.
  • The full Discord extension shard passed 221 files / 2,763 tests in 24.69 seconds after the timer-ownership repair.
  • Combined changed-file gate passed, including extension test types, lint, dead exports, formatting, environment/max-lines ratchets, plugin boundaries, and policy guards. Blacksmith Testbox is unavailable on this host, so the trusted-source wrapper used its documented local fallback.
  • Structured autoreview passed on the final patch with no actionable findings.
  • Exact-head CI run 31681281942 passed on 3017a05e890012e334b34ed2be4b668fab6d6caa.
  • git diff --check passed.
  • Production delta is zero. Tests and test support: +1,156 / -1,759 lines (net -603).

AI-assisted: yes. Every removed harness case was classified against direct owner coverage or a stronger real QA scenario before deletion.

@clawsweeper

clawsweeper Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Aug 13, 2026
@steipete
steipete marked this pull request as ready for review August 13, 2026 05:38
@openclaw-barnacle openclaw-barnacle Bot added size: XL maintainer Maintainer-authored PR channel: discord Channel integration: discord labels Aug 13, 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 Aug 13, 2026
@clawsweeper

clawsweeper Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 13, 2026, 4:20 AM ET / 08:20 UTC.

ClawSweeper review

What this changes

This PR replaces copied embedded-agent incomplete-turn runner suites with direct tests of recovery, terminal-resolution, and assistant-failure owners, and consolidates Discord send tests into one shared Vitest module.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for maintainer handling: the test-ownership refactor is consistent with the current recovery owners and has no discrete source-level regression finding, but the maintainer label and unfinished exact-head checks still gate landing.

Priority: P3
Reviewed head: 3017a05e890012e334b34ed2be4b668fab6d6caa
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a coherent owner-boundary test refactor with no actionable defect found; remaining confidence depends on the in-progress exact-head checks.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored, test-only refactor has no changed production behavior; the PR body additionally reports post-change Gateway scenarios.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored, test-only refactor has no changed production behavior; the PR body additionally reports post-change Gateway scenarios.
Evidence reviewed 6 items Current owner boundary: The embedded run loop delegates assistant errors to the assistant-failure owner and resolves terminal outcomes through the terminal-resolution owner, so testing those owners directly covers the actual decision boundary rather than a copied runner.
Direct recovery behavior: Current recovery and terminal-resolution owners guard retries around replay safety, visible output, side effects, silence, and finalization; the branch’s new tests call these owners directly.
Branch test coverage: The branch adds direct recovery, terminal-resolution, and assistant-failure tests while deleting the three copied incomplete-turn runner suites.
Findings None None.
Security None None.

How this fits together

Embedded agent attempts pass through recovery and terminal-resolution policy before OpenClaw produces a channel reply or an intentional silent outcome. The Discord test surface validates the transport’s outgoing message, asset, reaction, and retry behavior using one shared mock lifecycle.

flowchart LR
  A[Agent attempt] --> B[Recovery policy]
  B --> C[Assistant failure handling]
  C --> D[Terminal resolution]
  D --> E[Channel delivery]
  F[Discord send test module] --> E
  E --> G[Reply or intentional silence]
Loading

Decision needed

Question Recommendation
Should this maintainer-owned test refactor land once the current-head required checks are green? Land after green checks: Merge the refactor if the remaining exact-head checks finish successfully and no maintainer concern emerges.

Why: The PR carries the protected maintainer label and current-head verification is incomplete, so automated cleanup should not close or land it.

Before merge

  • Resolve merge risk (P1) - Exact-head checks are still running, so the full lint, type, and channel-test result for this branch has not yet been independently confirmed.
  • Complete next step (P2) - Protected maintainer handling and unfinished exact-head checks require a human landing review; no narrow repair task is currently indicated.
Agent review details

Security

None.

PR surface

Source +481, Tests -1084. Total -603 across 18 files.

View PR surface stats
Area Files Added Removed Net
Source 3 484 3 +481
Tests 15 672 1756 -1084
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 18 1156 1759 -603

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0; tests and test support +1,156/-1,759 (net -603) The branch changes only test and test-support surfaces while reducing the copied-runner test footprint.

Stored data model

Persistent data-model change detected: serialized state: src/agents/embedded-agent-runner/run.incomplete-turn.reasoning-recovery.test.ts, serialized state: src/agents/embedded-agent-runner/run/assistant-failure.test.ts, vector/embedding metadata: src/agents/embedded-agent-runner/run/incomplete-turn-resolution.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep incomplete-turn assertions at the recovery, terminal-resolution, and assistant-failure owners, retain the registered single-module Discord test split, and land after current-head checks complete green.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep incomplete-turn assertions at the recovery, terminal-resolution, and assistant-failure owners, retain the registered single-module Discord test split, and land after current-head checks complete green.

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

Not applicable: this PR refactors test ownership rather than reporting a new current-main product failure; its body reports focused Gateway scenarios as supporting validation.

Is this the best way to solve the issue?

Yes. The run loop calls the recovery, terminal-resolution, and assistant-failure owners directly, so placing assertions at those owners removes duplicated runner logic without changing production behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 3b6e54041f18.

Labels

Label justifications:

  • P3: This is a behavior-neutral test-ownership and test-structure cleanup with no claimed user-visible change.
  • 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: This maintainer-authored, test-only refactor has no changed production behavior; the PR body additionally reports post-change Gateway scenarios.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Authored the current settled-turn terminal-resolution implementation that this PR tests directly. (role: introduced current terminal-resolution owner; confidence: high; commits: 0b9842d138c0; files: src/agents/embedded-agent-runner/run/terminal-resolution.ts, src/agents/embedded-agent-runner/run/incomplete-turn-recovery.ts)
  • steipete: The current Discord send test split history includes the max-lines repair authored as Peter Steinberger, matching this maintainer’s repository identity. (role: recent Discord test-surface contributor; confidence: high; commits: 7c8f08a88ccc; files: extensions/discord/src/send.creates-thread.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let the current-head checks complete before landing.

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 (3 earlier review cycles)
  • reviewed 2026-08-13T06:08:59.641Z sha 267a528830a7a613fe3862a5e7115cc6714f1c77 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-13T06:19:39.043Z sha 1e25ba252cce0adcccf10272921433f2003249ba :: needs maintainer review before merge. :: none
  • reviewed 2026-08-13T07:06:16.387Z sha cb25ec4 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the test/audit-incomplete-turn-runner-mirror branch from 267a528 to 1e25ba2 Compare August 13, 2026 06:13
@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 Aug 13, 2026
@steipete
steipete force-pushed the test/audit-incomplete-turn-runner-mirror branch from 1e25ba2 to cb25ec4 Compare August 13, 2026 07:00
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for 3017a05e890012e334b34ed2be4b668fab6d6caa:

  • Root cause of the final CI timeout: Discord draft tests enabled the status-reaction lifecycle while freezing the shared clock for draft-delay assertions, so completion waited forever on an unrelated terminal hold. Draft tests now use a reaction-disabled context; reaction-specific tests drive their clock externally.
  • node scripts/run-vitest.mjs extensions/discord — 221 files / 2,763 tests passed in 24.69s.
  • node scripts/check-changed.mjs -- <six Discord timer-cleanup files> — passed, including extension test types, lint, dead exports, formatting, ratchets, and boundary checks. Blacksmith Testbox was unavailable on this host, so the trusted-source wrapper used its documented local fallback.
  • Final structured autoreview — clean, no actionable findings.
  • Exact-head CI run 31681281942 — green with no pending checks.
  • Current-head ClawSweeper review — no findings; its only rank-up move was to wait for exact-head CI, now satisfied.
  • Production delta: zero. Tests/test support: +1,156 / -1,759, net -603.

@steipete
steipete merged commit 792b205 into main Aug 13, 2026
124 checks passed
@steipete
steipete deleted the test/audit-incomplete-turn-runner-mirror branch August 13, 2026 08:29
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 14, 2026
* test(agents): move recovery tests to owners

* test(discord): split send coverage by surface

* test(discord): share send mock lifecycle

* test(discord): isolate draft timer coverage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: discord Channel integration: discord 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: 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