Repository navigation
test(main-session-recovery): consolidate main-session-restart-recovery.test.ts - #166028
Conversation
…y.test.ts Consolidate transcript, checkpoint, marker and notice cases while preserving all 158 integration scenarios and the distinct assertions they protect. Share exact-session reads, delivery setup and exclusive harness fixtures. Testbox: 158 tests pass before and after; 259.30s to 220.96s wall time. Three temporary production mutations fail their intended assertions. Independent review is clean. The changed gate passes except for an unchanged voice-call unused export reproduced on the original baseline.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 5:38 AM ET / 09:38 UTC (Revision 4). ClawSweeper reviewWhat this changesThe PR consolidates restart-recovery scenarios and shared test fixtures while preserving checks for saved session state, transcript safety, delivery, and lifecycle ordering. Merge readiness✅ Ready for maintainer review This remains a useful, distinct test cleanup; current main has not incorporated the consolidation. No actionable introduced defect was found, and the maintainer-authored PR should remain open for ordinary review. Likely related people: steipete — high-confidence routing candidate from prior merged recovery work. Priority: P3 Review scores
Verification
How this fits togetherMain-session recovery reads saved session state and transcripts after a Gateway restart to decide whether interrupted work should resume or settle. These tests exercise those decisions and their effects on delivery and session ownership. flowchart TD
A[Gateway restart] --> B[Saved sessions and transcripts]
B --> C[Recovery decision]
C --> D[Resume interrupted work]
C --> E[Settle completed work]
D --> F[Delivery and session state]
E --> F
G[Recovery test scenarios] --> C
Before mergeNone. Agent review detailsSecurityNone. PR surfaceTests -311. Total -311 across 3 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep the shared fixtures and scenario tables while retaining exact persisted-state, replay-safety, and delivery-boundary assertions. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR consolidates existing tests rather than fixing a reported product failure; its body records before/after suite runs and mutation checks. Is this the best way to solve the issue? Yes: local scenario tables and exclusive fixture helpers reduce repeated arrangements without adding a production seam or replacing the tested recovery boundary. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7b9405e22d7b. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
Rename the local factory to createChild so the core lint stripe accepts its surrounding child loops. Scenario inputs and assertions are unchanged. Testbox: typed lint passes for all three changed files; all six affected parent-recovery cases pass. Independent review is clean.
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…y.test.ts (openclaw#166028) * test(main-session-recovery): consolidate main-session-restart-recovery.test.ts Consolidate transcript, checkpoint, marker and notice cases while preserving all 158 integration scenarios and the distinct assertions they protect. Share exact-session reads, delivery setup and exclusive harness fixtures. Testbox: 158 tests pass before and after; 259.30s to 220.96s wall time. Three temporary production mutations fail their intended assertions. Independent review is clean. The changed gate passes except for an unchanged voice-call unused export reproduced on the original baseline. * test(main-session-recovery): avoid shadowing the child fixture Rename the local factory to createChild so the core lint stripe accepts its surrounding child loops. Scenario inputs and assertions are unchanged. Testbox: typed lint passes for all three changed files; all six affected parent-recovery cases pass. Independent review is clean.
What Problem This Solves
Consolidates repeated restart-recovery test arrangements and assertions while retaining the real SQLite, transcript, delivery, and lifecycle coverage.
User Impact
No user-visible behavior change. Production LOC delta: 0; this campaign explicitly limits changes to the assigned test and its exclusive harnesses.
Why This Change Was Made
Use scenario tables for transcript policy, restart markers, pending-delivery notice settlement, and recovery checkpoints. Reuse the existing exact message constructors, attach exact-session reads to the session fixture, and share the two delivery arrangements. Parent-child fixtures retain every missing-owner, missing-revision, successor, and ordering input. The harness-completion fixture shares prepared-final and ordinary-session arrangements.
main-session-restart-recovery.test.tsmain-session-parent-recovery.test-harness.tsmain-session-harness-completion.test-harness.tsmain-session-startup-repair.test-harness.tsmain-session-restart-recovery-fixture.test-support.tsThis uses the campaign's escape hatch: the 40% target is not met. No whole scenario was deleted. The remaining large
main-session-restart-recoverydescribe contains distinct integration contracts: active/store ownership and generation races; delivery and execution identity; reservation cleanup and ambiguous settlement; startup cancellation at separate await boundaries; and durable source-reply reconciliation. The smaller resume-policy and dispatch-start suites do not replace these persisted-state outcomes. Further major removal would discard coverage or replace direct arrangements with a more complex configurable fixture.The exclusive parent harness retains twelve distinct child identities and two replacement modes. Harness completion retains seven interruption phases, real SQLite payload corruption, and distinct delegated/internal/human authority outcomes. Startup repair retains the #165612 deferred-admission regression and real SQLite/Gateway-lock mixed-roster repair. The transcript fixture owns shared-root cleanup and is already 69 lines. The #165974-era cases and all issue-specific inputs remain.
Consolidated coverage map
preserves current-generation markers across repeated restart marking;replaces an older marker when the same run id is active after another restartcompletes an unqueued media-only final with owed notice debt;preserves an acknowledged notice when the same pending final completes;records notice debt for unknown delivery mixed with prepared workresumes with restart-safe tools while a terminal provider outcome remains unknown;resumes safely for a source-less silent before_agent_reply checkpoint;resumes safely for a %s before_agent_reply checkpoint without a recoverable resultresumes a pre-upgrade errored tail without an abort codereads a provider-native Code Mode wait inputwithholds Code Mode tools for an unsafe direct waiting checkpointkeeps restart safety after a failed Code Mode resultkeeps replay safety outside the recent transcript window under full accessresumes an in-flight safe tool call across a repeated restartretains replay safety after a provider error under full accessends prior replay restrictions at a new full-access user turnresumes safely without replaying visible assistant text beside a Code Mode waitkeeps partial provider-abort output under replay-safe recoveryresumes a partial streamed answer interrupted by a restartreports an interrupted native tool outcome as unknownkeeps a dangling side-effecting call in an aborted tail restrictedresumes an interrupted replay-safe tool call without restricting toolsresumes through the shutdown error persisted for an interrupted Code Mode waitresumes through the current Code Mode abort persisted for an interrupted waitresumes a mixed Code Mode wait and side-effecting tool tail safelydelivers a resumed reply through hooks using the interrupted routeretains exact hook context and delivered text/recipient; independent request facts remain.re-adopts a persisted Telegram private-topic route and releases the next turnretains the actual delivered recipient/text/thread and next-turn claim checks.No test-only production seam was removed. The out-of-scope production export-scan findings are recorded with baseline evidence below. Shared runtime/transcript support is unchanged; the changed harnesses are imported only by the assigned test.
Evidence
Final change base:
5592e6169e556a5f0562099b806f7765d728d532. Final head:05c3fbbcfc59f5110c82abcc63ca43a177a9a4db.All full-suite runs passed 158/158 tests, with no committed skipped tests. The final correction only renames the child-record fixture factory to avoid
eslint(no-shadow); typed lint for all three files and the six affected parent-recovery cases passed afterward. Independent P0–P2 reviews of the consolidation and lint correction are scoped-clean.Test cost
Every measurement used
pnpm test src/agents/main-session-recovery/main-session-restart-recovery.test.ts --maxWorkers=1onblacksmith-testbox, profileopenclaw-check. The fixed reverse-order pair was added after the first rebased pair showed a small increase; all measurements are reported here.58163bdb326f, baseline first5592e6169e55, baseline first5592e6169e55, candidate first, warm workersThe warm pair is +3.51 s (+1.8%) for the candidate. The two rebased pairs average 209.41 s baseline / 214.61 s candidate (+2.5%). Candidate timings varied by 23.69 s across these runs. No speedup is claimed, and the strict no-cost-growth condition is not conclusively demonstrated. There are no added cases, timers, process boots, or broader test imports.
Mutation sanity
Three temporary production faults were each caught by a focused
node scripts/run-vitest.mjs <file> --maxWorkers=1 -t <case>run. All production bytes were restored. The three mutated production modules are unchanged across the rebase.completes terminal deliveries despite a residual pending queue rowmarks queued abort-registry runs before lifecycle start changes session statusstartedAtundefined, got 1000.reads a provider-native Code Mode wait inputforceCodeModeTools: true, property missing.The Code Mode probe initially selected no test because Vitest abbreviates interpolated table labels. Its corrected unique-prefix filter selected the test and produced the intended assertion failure. Focused mutation runs deselect other cases; no
.skipor.onlywas added.Remote runs and gates
The CLI did not expose run URLs for these leases. Both leases were stopped after validation.
blacksmith-testbox/tbx_01m4834ty8vr8jsndwcbejz4q7pnpm test <file> --maxWorkers=1node scripts/run-vitest.mjsnode scripts/check-changed.mjs --stagedblacksmith-testbox/tbx_01m486fwvq75sy03aqdkx45xdznode scripts/check-changed.mjs --base 5592e6169e556a5f0562099b806f7765d728d532 --head 4161f8592b56a06f4ba6aa3da33875aba5332dfcnode --import tsx scripts/check-deadcode-exports.mtsnode scripts/run-oxlint.mjs --type-aware --tsconfig config/tsconfig/oxlint.core.json --threads=1 <three changed files>node scripts/run-vitest.mjs <file> --maxWorkers=1 -t 'resumes unfinished work after|gives the recovering parent current unfinished child identities'Out-of-scope production findings, reproduced on unchanged
5592e6169e55:extensions/voice-call/src/webhook/realtime-call-session-control.ts:OUTBOUND_GREETING_FALLBACK_MS.src/agents/model-catalog.runtime.ts:modelCatalogRuntime.loadManifestModelCatalog.The first full CI run failed only on the new factory's
childname shadowing loop variables. That was corrected tocreateChild, reviewed, and validated remotely before the follow-up push. Exact-final-head CI completed with 34 successful jobs, 25 skipped jobs, and one inherited root failure plus its aggregate gate. The corrected core lint job and all selected changed-test jobs passed.check-prod-typesfailed with TS18004 atrun-loop-shutdown-completion.test-support.ts:54:gatewayLogis referenced without a declaration. The job log records tested mergeba71809498d77387e22ca023a276f2d4a6101565, whose parents are main9ad97b209d6e29a9fd9208a85777a82bd81c6fe7and this PR's final head. The failing file has the identical blob563bb2cc97b9b8ae8e17462b832154f4eb55c29ein that main baseline and tested merge. Only this lane's three permitted files differ between those trees; no global declaration or CLI fixture is changed here. This independent missing local binding is outside the lane's editable scope. CI is therefore not green, and no failing check was bypassed. Auto-merge remains disabled; this PR is not merged.Changed-gate summary from the final Testbox lease
Final CI seconds for selected changed-test jobs
These are end-to-end job durations, including setup, rather than file-only measurements.
checks-node-changed-1checks-node-changed-boundarychecks-node-changed-3checks-node-changed-2checks-node-changed-compact-large-8