Skip to content

refactor(test): keep lifecycle resets out of production - #154669

Merged
steipete merged 2 commits into
mainfrom
codex/test-only-lifecycle-seams
Sep 21, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/test-only-lifecycle-seams

Conversation

@steipete

@steipete steipete commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Related: #150153.

What Problem This Solves

Production Gateway modules carry a chain of exports used only to reset test model catalogs, and session writer queues expose a private asynchronous test drain.

User Impact

No user-visible behavior change. Published SDK cache-clear APIs and production writer settlement remain unchanged.

Why This Change Was Made

Move the private reset and drain operations into test support, remove the production forwarding chain, and update callers together. The lazy-loading test now exercises Gateway startup itself. Production code shrinks by 63 lines.

Evidence

Independent review found no actionable issues. The current-main integration passed all 27 admission tests and focused types/lint. Earlier source-bound validation passed 300 owner and sibling tests, three synthetic Telegram Gateway flows, the build, type checks, and changed-code checks. The six production modules are unchanged by integration; the private drain bodies and published clear APIs retain their behavior. Current-head CI remains required.

The reset move exposed a malformed model fixture and an assertion that counted fixture preparation as read-side discovery; both now preserve the actual catalog contract. The Telegram replacement scenario now proves the admitted callback waits without premature edits or retries before replacement is published.

The Discord transcript-capture E2E also stalls at tool execution on the unchanged baseline. This PR updates its cleanup import and does not claim to fix that independent failure.

Test costs

Paired measurement compares baseline aa099e492dabc5e26c6ec0b5962bc637d5df1f7c with this exact 32c417a14414582b4045077a1926ee4545716c8c head on one AWS c7a.8xlarge host (Linux x86_64, Node 24.19.0, pnpm 12.4.0). Each complete file ran once through node scripts/run-vitest.mjs run <file> with verbose/JSON reporters, separate frozen installs, fresh homes/caches, and 431 matching dependency/configuration inputs. Both source trees remained clean.

Test file Before wall / Vitest After wall / Vitest Result per revision
server.lazy.test.ts 28.815s / 25.38s 17.498s / 14.16s 1 passed
server.models-voicewake-misc.test.ts 44.836s / 41.43s 44.987s / 41.64s 18 passed

These are single observations, not statistical performance or CI-savings claims. Setup/download time is excluded. An initial transport attempt failed before executing the payload; it was preserved and cleaned up before the script-only transfer succeeded. No test was retried or edited. Both proof leases are released with cleanup complete.

Current-head CI passed with 140 successful jobs and 17 skipped jobs. Workflow elapsed time was 1,296 seconds (21m36s), including scheduling and parallel work rather than accumulated CPU time. The required Security Review gate also passed.

Move private model-catalog resets and asynchronous writer drains into test support. Preserve shipped SDK clear APIs and exercise lazy Gateway activation through its real entry point.
@clawsweeper

clawsweeper Bot commented Sep 21, 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.

@steipete steipete self-assigned this Sep 21, 2026
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Sep 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 21, 2026, 6:30 AM ET / 10:30 UTC (Revision 3).

ClawSweeper review

What this changes

Moves private model-catalog resets and writer-queue drains into test support, updates their callers, and checks lazy Gateway loading through startup.

Merge readiness

✅ Ready for maintainer review

Keep open as useful, review-ready cleanup. The added measurements resolve the prior review’s timing request, and no actionable introduced defects were found.

Priority: P3
Reviewed head: 32c417a14414582b4045077a1926ee4545716c8c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, behavior-preserving cleanup with complete caller migration, useful validation, and the previous evidence request addressed.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored internal cleanup is exempt from external-contributor live proof; supplied Gateway test measurements and verified exact-head CI support the helper cutover without claiming live Telegram behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored internal cleanup is exempt from external-contributor live proof; supplied Gateway test measurements and verified exact-head CI support the helper cutover without claiming live Telegram behavior.
Evidence reviewed 8 items Pinned introduced change: Reviewed the complete introduced diff from aa099e4 to the original PR head. Production changes remove private test forwarding and drain functions; their implementations move into test support.
Drain behavior and published APIs preserved: The moved drain still rejects pending writes and awaits active drains. Repository-wide references point to the new test helpers, while clearSessionStoreCacheForTest remains exported through both existing SDK surfaces. Production queue execution and settlement are unchanged.
Behavioral assertions retained: The lazy-loading test now invokes startGatewayServer. Catalog tests measure discovery calls after fixture preparation, and the catalog owner explicitly normalizes an empty display name to the model ID. The Telegram replacement test retains completion assertions and checks that publication waiting produces neither premature edits nor retry attempts.
Findings None None.
Security None None.

How this fits together

The Gateway prepares model catalogs for agent requests, while writer queues serialize session updates. Test fixtures reset these owners between cases; production startup and write settlement remain unchanged.

flowchart TD
  A[Test fixtures] --> B[Test lifecycle helpers]
  B --> C[Reset prepared model catalogs]
  B --> D[Await active writer drains]
  C --> E[Isolated next test]
  D --> E
  F[Gateway startup] --> G[Production runtime owners]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -63, Tests +69. Total +6 across 29 files.

View PR surface stats
Area Files Added Removed Net
Source 7 4 67 -63
Tests 22 117 48 +69
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 29 121 115 +6

Review metrics

None.

Technical review

Best possible solution:

Keep private lifecycle cleanup in test support while preserving production startup, writer settlement, and published SDK clear contracts.

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

Not applicable: this refactor addresses source organization rather than a reported runtime defect; current main confirms the private production exports still exist.

Is this the best way to solve the issue?

Yes: moving the existing helpers and their callers together removes unnecessary production surface without adding a competing runtime owner.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is internal test-boundary cleanup with no intended user-visible behavior 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: The maintainer-authored internal cleanup is exempt from external-contributor live proof; supplied Gateway test measurements and verified exact-head CI support the helper cutover without claiming live Telegram behavior.

Evidence

What I checked:

  • Pinned introduced change: Reviewed the complete introduced diff from aa099e4 to the original PR head. Production changes remove private test forwarding and drain functions; their implementations move into test support. (src/agents/prepared-model-runtime.test-support.ts:13, 32c417a14414)
  • Drain behavior and published APIs preserved: The moved drain still rejects pending writes and awaits active drains. Repository-wide references point to the new test helpers, while clearSessionStoreCacheForTest remains exported through both existing SDK surfaces. Production queue execution and settlement are unchanged. (test/helpers/promise.ts:6, 32c417a14414)
  • Behavioral assertions retained: The lazy-loading test now invokes startGatewayServer. Catalog tests measure discovery calls after fixture preparation, and the catalog owner explicitly normalizes an empty display name to the model ID. The Telegram replacement test retains completion assertions and checks that publication waiting produces neither premature edits nor retry attempts. (src/gateway/server.lazy.test.ts:45, 32c417a14414)
  • Prior timing request resolved: The supplied PR-body snapshot records paired baseline/head measurements: server.lazy.test.ts wall time 28.815s to 17.498s and server.models-voicewake-misc.test.ts 44.836s to 44.987s, with matching passing case counts. It also reports 1,296 seconds of CI workflow elapsed time and correctly avoids statistical performance claims. This addresses the previous completed review’s sole required follow-up. (32c417a14414)
  • Exact-head CI verified: GitHub reports workflow run 35583734173 completed successfully for the pinned PR head, running from 09:30:57 to 09:52:33 UTC. Tests and builds were not executed during this read-only review. (32c417a14414)
  • Cleanup remains necessary on current main: Fetched main still exposes resetPreparedModelCatalogForTest in the Gateway entrypoint and drainStoreWriterQueuesForTest in the production queue module. No verified merged replacement establishes that this cleanup is already implemented or released. (src/gateway/server.ts:105, b95f9005280f)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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 (2 earlier review cycles)
  • reviewed 2026-09-21T09:10:51.269Z sha c843ae9 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-21T09:37:54.184Z sha 32c417a :: needs changes before merge. :: none

@steipete
steipete marked this pull request as ready for review September 21, 2026 09:30
@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 21, 2026
@steipete
steipete merged commit aabfaf9 into main Sep 21, 2026
281 of 284 checks passed
@steipete
steipete deleted the codex/test-only-lifecycle-seams branch September 21, 2026 10:32
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 22, 2026
)

* refactor(test): keep lifecycle resets out of production

Move private model-catalog resets and asynchronous writer drains into test support. Preserve shipped SDK clear APIs and exercise lazy Gateway activation through its real entry point.

* chore: merge main into lifecycle test cleanup

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime 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: M 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