Skip to content

fix(test): stop Doctor integrity teardown from breaking commands - #163777

Merged
steipete merged 1 commit into
mainfrom
fix/red-main-doctor-state-integrity
Oct 2, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/red-main-doctor-state-integrity

Conversation

@steipete

@steipete steipete commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes red main: doctor-state-integrity.test.ts fails a retained-session receipt assertion and file teardown, then contaminates later files in the shared commands worker.

User Impact

No product or update behavior changes. The existing Doctor integrity tests now finish their database cleanup before retiring their temporary state.

Why This Change Was Made

Introduced by d6929f854d2e9d58b1482aad072cc5da7f4bafcf (#163378), which moved the fixture's session upserts into native workers. The fixture still used synchronous close helpers and immediately deleted its home. A later import's maintenance drain encountered the retained cleanup failure, so compaction failed and the verified receipt was correctly withheld; final file drainage failed for the same reason.

Await the existing scoped session-state cleanup owner before restoring the environment and deleting the fixture root. Every assertion is unchanged, including canonical repair, the continued absence of deleted rows, original source bytes, and the import receipt. The existing test guards the regression; no additional test or production path is needed.

Evidence

  • Node 24 boundary bisection: raw parent 4e9dec17f323e8d4839d3668bf25c138cb87be4e passes 15/15; the introducing commit reproduces both failures (14/15 plus file-level ENOENT). Current-main baseline reproduces the same failures.
  • Repaired file: five consecutive Node 24 runs pass 15/15 each. Measured single-file runner walls: 128, 66, 44, 33, and 141 seconds on a shared host; includes worker compilation/cache verification. No new test cases or timeouts.
  • Five consecutive Bun 1.4.3-canary runs also pass 15/15 each (runner walls 50, 35, 41, 25, and 31 seconds).
  • node scripts/check-changed.mjs completed with captured exit 0, including the affected Doctor test type graph and lint.
  • Full commands config under Node 24.19, retaining shared workers and a four-worker envelope: 543 files passed; 6,824 tests passed, four skipped; exit 0 in 1,414.37s Vitest wall on Blacksmith Testbox. The uploaded test source hash matches the locally proven file. The provider completed successfully and stopped its one-shot lease; its backing Actions job may appear cancelled during lease cleanup.
  • Exact-head CI is green without reruns. ClawSweeper completed review of 7d0bfbfee01232bcdecbbc54dc4ea1c9b1467df5 with no actionable findings.
  • Independent Codex autoreview is scoped-clean through P2; Madge reports zero import cycles; diff and formatting checks pass.

Await the scoped session-state cleanup owner before restoring fixture environment selectors and removing the temporary home. This joins session writers, native agent resources, and shared-state cleanup without changing assertions.

Fixes red main introduced by d6929f8 (#163378). Its parent passes all 15 tests; the commit reproduces the missing import receipt and file-level custody error. The fix passes five consecutive Node 24 runs and five Bun runs, check-changed, and P2 autoreview.
@clawsweeper

clawsweeper Bot commented Oct 2, 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 commands Command implementations size: XS labels Oct 2, 2026
@steipete
steipete marked this pull request as ready for review October 2, 2026 20:52
@steipete

steipete commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Red-main fixture repair at 7d0bfbf. The introducing commit and its passing parent are verified, all original assertions remain unchanged, and five consecutive Node and Bun runs pass. Independent P2 autoreview and check-changed pass. The full shared-worker commands run remains in progress as linked in the body.

@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Oct 2, 2026
@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 2, 2026, 5:20 PM ET / 21:20 UTC (Revision 2).

ClawSweeper review

What this changes

The Doctor integrity tests await session and database cleanup before restoring their environment and deleting their temporary home.

Merge readiness

✅ Ready for maintainer review

The repair remains necessary on current main. No actionable correctness or security findings remain, and exact-head CI passed.

Priority: P2
Reviewed head: 7d0bfbfee01232bcdecbbc54dc4ea1c9b1467df5

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-based repair preserves all assertions and has successful exact-head CI plus detailed reported regression validation.
Proof confidence 🌊 off-meta tidepool Not applicable: This verified repository-admin repair changes only test teardown, so contributor product-runtime proof is exempt. Reported before/after Doctor tests exercise the changed fixture lifecycle, supplemented by verified exact-head CI; no stored-data contract changes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This verified repository-admin repair changes only test teardown, so contributor product-runtime proof is exempt. Reported before/after Doctor tests exercise the changed fixture lifecycle, supplemented by verified exact-head CI; no stored-data contract changes.
Evidence reviewed 9 items Verified introduced change: The pinned introduction delta only replaces synchronous database closes with awaited scoped cleanup. Test assertions are unchanged.
Cleanup ownership and ordering: The existing helper drains writer queues, transcript reconciles, and file locks; closes scoped auth readers; then awaits agent database retirement before shared-state closure.
Production lifecycle boundary: Asynchronous agent closure drains retained resources and pending opens, awaits WAL maintenance shutdown, and then closes cached databases.
Findings None None.
Security None None.

How this fits together

Doctor checks and repairs OpenClaw state. Its integrity tests use temporary session databases whose background workers must finish before those fixtures are removed.

flowchart TD
  A[Doctor integrity tests] --> B[Temporary session databases]
  B --> C[Background session workers]
  C --> D[Await shared cleanup owner]
  D --> E[Restore test environment]
  E --> F[Remove temporary home]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests -2. Total -2 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 3 5 -2
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 3 5 -2

Review metrics

None.

Technical review

Best possible solution:

Use the existing awaited cleanup owner while preserving the integrity assertions and shared-worker execution.

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

Yes, source establishes that the baseline deletes its fixture without awaiting background database retirement, and the PR reports before/after failures and passes. This review did not execute tests.

Is this the best way to solve the issue?

Yes, using the existing scoped cleanup owner fixes the fixture lifetime without weakening assertions, adding timeouts, or changing production behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded test-fixture lifecycle repair with no product behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This verified repository-admin repair changes only test teardown, so contributor product-runtime proof is exempt. Reported before/after Doctor tests exercise the changed fixture lifecycle, supplemented by verified exact-head CI; no stored-data contract changes.

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)

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-10-02T20:56:37.603Z sha 7d0bfbf :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 85d1ef6 into main Oct 2, 2026
184 checks passed
@steipete
steipete deleted the fix/red-main-doctor-state-integrity branch October 2, 2026 21:25
@steipete

steipete commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Oct 2, 2026
## What Problem This Solves

Commands, Doctor, and infrastructure repeat option forwarding, migration traversal, result projection, and error handling that already have canonical owners.

## User Impact

No intended user-visible change. CLI flags, messages, exit codes, JSON output, migration precedence, persisted data, and authorization checks stay unchanged. Supported July 2026-and-later migrations and the older-Gateway node-list fallback remain supported.

## Why This Change Was Made

This combines the subsystem cleanup into one batch, removing 1,459 net production lines instead of paying for separate CI runs for each small simplification.

- Consolidate onboarding installation, auth selection, migration item selection, and cleanup reporting; retain branch-specific consent and error behavior.
- Reuse Doctor's model-slot traversal, parsing, package identification, report projection, and session-key collection instead of parallel implementations and forwarding helpers.
- Let status reports consume their existing overview facts directly, and share archive/storage command registration.
- Map device-pairing authority refusals at the mutation owner after admission and publication settle; preserve locks, revalidation, cleanup, and each caller's return shape.
- Consolidate receipt-authoritative APNs/MCP source cleanup at the source-claim owner, keeping each migration's safe reader and receipt commit.
- Remove redundant outbound target forwarding and reuse existing filesystem, normalization, and text helpers.

Updater lifecycle, dependencies, schemas, and plugin SDK contracts are unchanged. The native assertion-baseline tool records five removed assertions; no allowance grows. No newly discovered product bugs or flaky-test fixes are included.

## Evidence

- Both import-cycle checks passed again on the final rebased head: 0 Madge cycles and 0 runtime-value cycles.
- AWS focused run: 3,324 passed, 2 skipped, and one inherited Doctor fixture failure across 174 files. The same failure reproduced on the clean base. The branch now includes the upstream repair from #163777; no duplicate fix is included.
- The complete changed-file gate passed, including production/test types, lint, dead exports, boundaries, and ratchets. The final Gateway send rerun passed all 83 tests. Git range-diff confirms the rebase preserved the cleanup patch.
- After the final Testbox exceeded the ten-minute queue limit, the local `nice -n 15` confirmation completed with 82 Gateway tests passing and one 120-second timeout in the Telegram live-owner test; Doctor did not run because the first group failed. Native worker compilation took 566 seconds under severe host load. The failure is recorded, not counted as passing proof.
- Exact-head CI [37074925001](https://github.com/openclaw/openclaw/actions/runs/37074925001) passed types, lint, architecture, builds, Windows, and most test shards. Five test jobs failed; every failure has matching pre-existing evidence below. The tests and the relevant refusal, worker-admission, session mutation, and cache-validity owners are unchanged by this cleanup. Landing uses the maintainer-authorized inherited-failure exception, pinned to `714c365b1775c10760276a4dbc8bbf05141d4e5d`; no green-CI claim is made.
- Independent autoreview is scoped-clean at P0/P1 after supplying unchanged owner context: the early ref-mode branch still enforces env-reference precedence; all migration command entrypoints retain the Codex-only flag guard; the cleanup serializer already normalizes local paths while delegated paths bypass it. Existing tests cover all three contracts.
- Blacksmith admission expired before checkout ([run](https://github.com/openclaw/openclaw/actions/runs/37057668205)); validation moved to direct AWS Linux compute.

Release-note context: internal cleanup only; no operator action or migration required.

### CI failure attribution

| PR job | Failure | Baseline evidence |
| --- | --- | --- |
| `checks-node-changed-compact-small-18` | `session-reaper.test.ts`: shared exact store discovers `[main]` instead of `[main, ops]` | Same assertion on [main run 37072934260](https://github.com/openclaw/openclaw/actions/runs/37072934260/job/111056682704). |
| `checks-node-changed-compact-large-1` | `session-sharing-groups.test.ts`: expected seeded host database to be defined | Same error on [main run 37072934260](https://github.com/openclaw/openclaw/actions/runs/37072934260/job/111056682541). Worker-backed seeding no longer promises an open host database. |
| `checks-node-changed-compact-large-21` | `doctor-config-preflight.test.ts`: retired Discord channel `allow` fixture refused | Same test/error on [independent PR run 37071278542](https://github.com/openclaw/openclaw/actions/runs/37071278542/job/111051475776). Discord retirement predates this cleanup. |
| `checks-node-changed-1` | `doctor.auth-profile-consumers.e2e.test.ts`: two maintenance-entry refusals | Same cases/error on [independent PR run 37071278542](https://github.com/openclaw/openclaw/actions/runs/37071278542/job/111051475801). The fixture starts asynchronous worker retirement through a synchronous close, then blocks the parent event loop with `spawnSync`. |
| `checks-node-changed-compact-large-6` | `session-accessor.sqlite-data-version.test.ts`: identical values lose object identity after transcript append | Same test/identity assertion on [independent PR run 37071278542](https://github.com/openclaw/openclaw/actions/runs/37071278542/job/111051475748). The changed fingerprint parser is used by quarantine-receipt decoding, not this cache validity path. |

The session-sharing job additionally failed `rechecks group members at transaction admission for a defaults update`: the mutation correctly rejected revoked authorization, but the broad worker-admission spy observed a commit (`true` instead of `false`). The exact test, error, and assertion at line 409 also failed on [main run 37067275144](https://github.com/openclaw/openclaw/actions/runs/37067275144/job/111038492452), before this PR. It passed in the next hourly main run, so that later pass is not presented as a repair. Its underlying race remains coordinator-owned. No tests, timeouts, assertions, or admission checks have been weakened.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 3, 2026
…nclaw#163777)

Fix red main introduced by 9d1cf78 (openclaw#163378): the Doctor fixture removed its state before native cleanup settled, breaking import receipt validation and subsequent shared-worker teardown.

Await the existing scoped session-state cleanup owner before restoring the environment and deleting the fixture root. Preserve every assertion.

Proof: five consecutive 15/15 runs on both Node 24 and Bun; full shared-worker commands config passes 543 files and 6,824 tests (four skipped); check-changed, independent P2 review, exact-head CI, and ClawSweeper pass.
Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 3, 2026
…w#163840)

## What Problem This Solves

Commands, Doctor, and infrastructure repeat option forwarding, migration traversal, result projection, and error handling that already have canonical owners.

## User Impact

No intended user-visible change. CLI flags, messages, exit codes, JSON output, migration precedence, persisted data, and authorization checks stay unchanged. Supported July 2026-and-later migrations and the older-Gateway node-list fallback remain supported.

## Why This Change Was Made

This combines the subsystem cleanup into one batch, removing 1,459 net production lines instead of paying for separate CI runs for each small simplification.

- Consolidate onboarding installation, auth selection, migration item selection, and cleanup reporting; retain branch-specific consent and error behavior.
- Reuse Doctor's model-slot traversal, parsing, package identification, report projection, and session-key collection instead of parallel implementations and forwarding helpers.
- Let status reports consume their existing overview facts directly, and share archive/storage command registration.
- Map device-pairing authority refusals at the mutation owner after admission and publication settle; preserve locks, revalidation, cleanup, and each caller's return shape.
- Consolidate receipt-authoritative APNs/MCP source cleanup at the source-claim owner, keeping each migration's safe reader and receipt commit.
- Remove redundant outbound target forwarding and reuse existing filesystem, normalization, and text helpers.

Updater lifecycle, dependencies, schemas, and plugin SDK contracts are unchanged. The native assertion-baseline tool records five removed assertions; no allowance grows. No newly discovered product bugs or flaky-test fixes are included.

## Evidence

- Both import-cycle checks passed again on the final rebased head: 0 Madge cycles and 0 runtime-value cycles.
- AWS focused run: 3,324 passed, 2 skipped, and one inherited Doctor fixture failure across 174 files. The same failure reproduced on the clean base. The branch now includes the upstream repair from openclaw#163777; no duplicate fix is included.
- The complete changed-file gate passed, including production/test types, lint, dead exports, boundaries, and ratchets. The final Gateway send rerun passed all 83 tests. Git range-diff confirms the rebase preserved the cleanup patch.
- After the final Testbox exceeded the ten-minute queue limit, the local `nice -n 15` confirmation completed with 82 Gateway tests passing and one 120-second timeout in the Telegram live-owner test; Doctor did not run because the first group failed. Native worker compilation took 566 seconds under severe host load. The failure is recorded, not counted as passing proof.
- Exact-head CI [37074925001](https://github.com/openclaw/openclaw/actions/runs/37074925001) passed types, lint, architecture, builds, Windows, and most test shards. Five test jobs failed; every failure has matching pre-existing evidence below. The tests and the relevant refusal, worker-admission, session mutation, and cache-validity owners are unchanged by this cleanup. Landing uses the maintainer-authorized inherited-failure exception, pinned to `714c365b1775c10760276a4dbc8bbf05141d4e5d`; no green-CI claim is made.
- Independent autoreview is scoped-clean at P0/P1 after supplying unchanged owner context: the early ref-mode branch still enforces env-reference precedence; all migration command entrypoints retain the Codex-only flag guard; the cleanup serializer already normalizes local paths while delegated paths bypass it. Existing tests cover all three contracts.
- Blacksmith admission expired before checkout ([run](https://github.com/openclaw/openclaw/actions/runs/37057668205)); validation moved to direct AWS Linux compute.

Release-note context: internal cleanup only; no operator action or migration required.

### CI failure attribution

| PR job | Failure | Baseline evidence |
| --- | --- | --- |
| `checks-node-changed-compact-small-18` | `session-reaper.test.ts`: shared exact store discovers `[main]` instead of `[main, ops]` | Same assertion on [main run 37072934260](https://github.com/openclaw/openclaw/actions/runs/37072934260/job/111056682704). |
| `checks-node-changed-compact-large-1` | `session-sharing-groups.test.ts`: expected seeded host database to be defined | Same error on [main run 37072934260](https://github.com/openclaw/openclaw/actions/runs/37072934260/job/111056682541). Worker-backed seeding no longer promises an open host database. |
| `checks-node-changed-compact-large-21` | `doctor-config-preflight.test.ts`: retired Discord channel `allow` fixture refused | Same test/error on [independent PR run 37071278542](https://github.com/openclaw/openclaw/actions/runs/37071278542/job/111051475776). Discord retirement predates this cleanup. |
| `checks-node-changed-1` | `doctor.auth-profile-consumers.e2e.test.ts`: two maintenance-entry refusals | Same cases/error on [independent PR run 37071278542](https://github.com/openclaw/openclaw/actions/runs/37071278542/job/111051475801). The fixture starts asynchronous worker retirement through a synchronous close, then blocks the parent event loop with `spawnSync`. |
| `checks-node-changed-compact-large-6` | `session-accessor.sqlite-data-version.test.ts`: identical values lose object identity after transcript append | Same test/identity assertion on [independent PR run 37071278542](https://github.com/openclaw/openclaw/actions/runs/37071278542/job/111051475748). The changed fingerprint parser is used by quarantine-receipt decoding, not this cache validity path. |

The session-sharing job additionally failed `rechecks group members at transaction admission for a defaults update`: the mutation correctly rejected revoked authorization, but the broad worker-admission spy observed a commit (`true` instead of `false`). The exact test, error, and assertion at line 409 also failed on [main run 37067275144](https://github.com/openclaw/openclaw/actions/runs/37067275144/job/111038492452), before this PR. It passed in the next hourly main run, so that later pass is not presented as a repair. Its underlying race remains coordinator-owned. No tests, timeouts, assertions, or admission checks have been weakened.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations P2 Normal backlog priority with limited blast radius. 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