Skip to content

fix: keep reply tests inside owned state - #132937

Merged
steipete merged 1 commit into
mainfrom
steipete/fix-reply-test-state-isolation-20260829
Aug 30, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/fix-reply-test-state-isolation-20260829

Conversation

@steipete

@steipete steipete commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor
Additional instructions

This is a same-repository branch so maintainers can update it directly.

What Problem This Solves

Resolves a problem where developers running auto-reply tests could read or create shared temporary session and workspace state instead of using the test's owned fixtures. This made the affected tests depend on other runs and could contaminate shared temporary directories.

Why This Change Was Made

Remove the hardcoded agent/workspace resolver overrides and let the tests exercise canonical path resolution. Real-I/O cases now use the existing owned-state fixture and its cleanup lifecycle, while keeping fast mode and real SQLite accessors intact.

Containment assertions check the actual resolved workspace and SQLite destination before reply execution. Obsolete full-initializer data and superseded direct-module mocks are removed rather than maintaining parallel mock paths. Production behavior, configuration, schemas, dependencies, timeouts, and cache policies are unchanged by this PR.

The earlier conflict repair incorporates #132960 (shared-temporary-state test isolation). Its block-streaming safety outcome is preserved through the canonical OpenClaw test-state helper instead of maintaining a second temporary-directory lifecycle. The shared resolver overrides and the remaining real-I/O fixtures still needed this repair.

User Impact

No user-facing runtime change from this PR. The affected reply tests use private, lifecycle-owned state while retaining their callback, final-payload, model-selection, native-status, and full/prepared-runtime expectations.

Evidence

Current head: 9ba6eee2c80ddd87974a7a63103815198ca03e98, mechanically rebased onto be5e79ca4713c33a11ccd56b2d728c19f0779f3d. All five changed file blobs and the complete patch are byte-identical to the previously reviewed repair at 4acf1fe5d37f32f45714040023376f8452bc23d4.

Fresh current-head proof

  • 119 passed, 0 failed, 0 skipped across 9 files in 67.717 seconds: the original 91-test reply neighborhood, plus 15 existing Code Mode recovery cases and 13 existing client-tool cases. These were executed on this head, not borrowed from another PR's proof.
  • Node 24.15.0, pinned pnpm 12.1.0, process-lifetime private state, and a clean-whitelist environment. The inherited recovery tests use fake tools/in-memory state; captured skill content avoids fixture-file reads, and the real guest worker uses installed assets and its normal cleanup.
  • Focused core typecheck passed in 9.118 seconds. Formatting of all five changed files and git diff --check passed. Source identity remained unchanged throughout proof.
  • Production LOC: +0/-0. Tests and test support: +254/-301 (net -47). The native classifier treats get-reply.test-mocks.ts as runtime by filename, but it is test support; its actual consumer behavior is covered.

Retained proof and CI recovery

  • Historical guarded RED proof is retained from the original pre-repair base: the block fixture failed its SQLite containment assertion and the shared fast-path fixture failed its actual workspace-resolver containment assertion, both before reply execution. Both then passed after the ownership repair; this does not claim the subsequently repaired upstream block fixture still fails.
  • The complete classified core and coreTests aggregate passed on 4acf1fe5d37f32f45714040023376f8452bc23d4 in 451.498 seconds. That full aggregate remains prior-head evidence; the current head has the fresh focused proof above and requires new exact-head CI for integration.
  • The clean isolated Codex P0 review applies to the exact unchanged patch, SHA256 35c56e886b43c4f19e0150f8dcf635b40c874b1a4fd439197cc5f02ea2b73d45. No semantic edits were made during this rebase.
  • CI run 33298729154, attempt 1 failed while building the old head's merge with newer main. The upstream metadata extraction had moved getPluginToolSideEffectOwnerKey but missed the import in code-mode-reconciliation.ts; build, lint, type, and package-boundary jobs failed with the same missing export. All failed-job logs and original proof are retained.
  • The canonical repair is fix(agents): import the side-effect owner key from the module that exports it #133155 (Code Mode metadata import), by @edenfunf, merged as be5e79ca4713c33a11ccd56b2d728c19f0779f3d. This PR inherits that landed fix rather than duplicating it. The rebase was triggered by failed merge-ref CI, not merely moving main; the old immutable failed run was not retried.
  • The latest completed ClawSweeper review found no introduced code or security defect. Its remaining rank-up action—confirm current-head required checks—remains a landing gate, along with normal maintainer handling. No duplicate clean review was requested merely for the mechanical rebase.

Executed current-head behavior command:

node --import ./scripts/tsx.mjs scripts/test-projects-serial.mts \
  src/auto-reply/reply.block-streaming.test.ts \
  src/auto-reply/reply/get-reply.fast-path.test.ts \
  src/auto-reply/reply/get-reply.turn-model-selection-differential.test.ts \
  src/auto-reply/reply/get-reply.message-hooks.test.ts \
  src/auto-reply/reply/get-reply.auto-fallback.test.ts \
  src/auto-reply/reply/get-reply.reset-hooks-fallback.test.ts \
  src/auto-reply/reply/get-reply.config-override.test.ts \
  src/agents/embedded-agent-runner/run/code-mode-reconciliation.test.ts \
  src/agents/embedded-agent-runner/run/attempt-client-tools.test.ts \
  -- --passWithNoTests=false --reporter=default --reporter=json

Executed current-head typecheck:

node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental \
  --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo

This is test-only proof; no live provider, channel, or UI verification is claimed. AI-assisted implementation and review.

@clawsweeper

clawsweeper Bot commented Aug 30, 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 size: L maintainer Maintainer-authored PR labels Aug 30, 2026
@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 Aug 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 3:51 AM ET / 07:51 UTC.

ClawSweeper review

What this changes

The branch replaces shared temporary-path and resolver mocks in five auto-reply test files with lifecycle-owned OpenClaw test state and containment assertions.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for maintainer handling: the PR remains a distinct test-isolation repair on current main, has no introduced correctness or security defect found, and exact-head checks are still incomplete.

Priority: P3
Reviewed head: 9ba6eee2c80ddd87974a7a63103815198ca03e98

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused test-only refactor appears sound with no actionable finding; exact-head checks remain the remaining landing gate.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored, test-only change has no user-visible behavior to demonstrate; the supplied focused test run is supplemental validation, not a real-behavior claim.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored, test-only change has no user-visible behavior to demonstrate; the supplied focused test run is supplemental validation, not a real-behavior claim.
Evidence reviewed 7 items Introduced surface: The verified merge-base-to-head delta changes only five auto-reply test and test-support files; no production runtime, configuration, schema, dependency, or workflow file is introduced.
Owned-state lifecycle: The shared fixture creates a unique canonical temporary root, applies its state environment, and performs session cleanup, environment restoration, and root removal in its cleanup path.
Relevant reply boundary: Reply setup resolves the agent workspace before either fast-test mkdir or normal workspace provisioning, so configuring that resolver with fixture-owned paths is the correct containment boundary.
Findings None None.
Security None None.

How this fits together

Auto-reply tests configure a workspace and session store before invoking reply setup, native command handling, and session access. The test-state helper owns those paths and cleans them up after each scenario.

flowchart LR
A[Test configuration] --> B[Owned test state]
B --> C[Workspace and session paths]
C --> D[Auto-reply setup]
D --> E[Reply and session assertions]
Loading

Before merge

  • Resolve merge risk (P1) - The current-head check snapshot is incomplete because build-artifacts is still in progress; merge only after required checks complete successfully on this head.
  • Complete next step (P2) - This protected, MEMBER-authored PR needs normal maintainer handling and completion of the current exact-head checks, not an automated repair lane.
Agent review details

Security

None.

PR surface

Source -2, Tests -45. Total -47 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 1 0 2 -2
Tests 4 254 299 -45
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 254 301 -47

Review metrics

Metric Value Why it matters
Production versus test delta production +0/-0; tests and test support +254/-301 (net -47) The repair changes only test fixtures and removes more test code than it adds, leaving runtime behavior and public contracts untouched.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the shared owned-state helper and containment assertions, then complete exact-head CI and maintainer review before landing.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the shared owned-state helper and containment assertions, then complete exact-head CI and maintainer review before landing.

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

Not applicable to a user-facing bug: this PR repairs test fixture ownership, and its body supplies focused test evidence rather than a product-runtime reproduction.

Is this the best way to solve the issue?

Yes. Reusing the lifecycle-owned test-state helper at the workspace and session-path boundary is preferable to maintaining local resolver overrides and parallel cleanup paths.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 93468cbbbdd9.

Labels

Label justifications:

  • P3: This is low-risk test maintenance intended to prevent false failures without changing user-facing runtime 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: This MEMBER-authored, test-only change has no user-visible behavior to demonstrate; the supplied focused test run is supplemental validation, not a real-behavior claim.

Evidence

What I checked:

Likely related people:

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

Rank-up moves

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

  • Let required checks finish successfully on the current head, then complete normal maintainer review.

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 (2 earlier review cycles)
  • reviewed 2026-08-30T00:34:20.845Z sha a898fb9 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-30T07:21:03.683Z sha 4acf1fe5d37f32f45714040023376f8452bc23d4 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the steipete/fix-reply-test-state-isolation-20260829 branch from a898fb9 to 4acf1fe Compare August 30, 2026 07:13
@steipete
steipete marked this pull request as ready for review August 30, 2026 07:14
@steipete
steipete force-pushed the steipete/fix-reply-test-state-isolation-20260829 branch from 4acf1fe to 9ba6eee Compare August 30, 2026 07:44
@steipete

Copy link
Copy Markdown
Contributor Author

Maintainer verification is complete for 9ba6eee2c80ddd87974a7a63103815198ca03e98.

The fixture producer was the problem: fast reply initialization bypassed the mocked full initializer, leaving shared absolute workspace/session paths reachable through real filesystem and SQLite owners. The five-file repair uses the existing lifecycle-owned test state, removes stale resolver/initializer mocks, and checks containment before reply execution. It preserves the earlier block-fixture isolation from #132960 without keeping competing temporary-root owners.

Fresh current-head proof passed 119/119 tests across nine files, with no skipped cases: 91 reply tests, 15 existing Code Mode recovery tests, and 13 client-tool cases. Core typechecking, formatting and diff checks passed. The complete classified aggregate passed on the previous head, and all five changed file blobs plus the full reviewed patch remained identical through the mechanical rebase. The independent isolated Codex P0 review therefore still covers those exact bytes.

The original failed merge-ref CI run is preserved, not hidden by a retry. It inherited a missing metadata import from main. The canonical import repair in #133155, contributed by @edenfunf, is now in this branch's base. The fresh exact-head CI run 33299918241, attempt 1 completed successfully.

The latest ClawSweeper review found no introduced correctness or security defect. Its remaining check-completion and normal-maintainer-handling steps are now satisfied. Native review artifacts validated and prepare-run completed with the same prepared/remote head and hosted gates passing.

Current local proof commands:

node --import ./scripts/tsx.mjs scripts/test-projects-serial.mts src/auto-reply/reply.block-streaming.test.ts src/auto-reply/reply/get-reply.fast-path.test.ts src/auto-reply/reply/get-reply.turn-model-selection-differential.test.ts src/auto-reply/reply/get-reply.message-hooks.test.ts src/auto-reply/reply/get-reply.auto-fallback.test.ts src/auto-reply/reply/get-reply.reset-hooks-fallback.test.ts src/auto-reply/reply/get-reply.config-override.test.ts src/agents/embedded-agent-runner/run/code-mode-reconciliation.test.ts src/agents/embedded-agent-runner/run/attempt-client-tools.test.ts -- --passWithNoTests=false --reporter=default --reporter=json
node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfo
OPENCLAW_TESTBOX=1 scripts/pr prepare-run 132937

Production +0/-0; tests/support +254/-301, net -47. This is test-isolation proof, not live provider, channel, UI, or deployment verification. Proceeding through the native pinned-head merge gate.

@steipete
steipete merged commit eb3e09b into main Aug 30, 2026
114 checks passed
@steipete
steipete deleted the steipete/fix-reply-test-state-isolation-20260829 branch August 30, 2026 08:01
@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

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: L 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