Skip to content

fix(tests): restore wake ordering and native usage settlement - #184427

Merged
steipete merged 1 commit into
mainfrom
steipete/fix-main-reds-model-switch-wake-usage-20261026
Oct 26, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/fix-main-reds-model-switch-wake-usage-20261026

Conversation

@steipete

@steipete steipete commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes false session-entry conflicts during native usage finalization and updates a stale restored-wake ordering expectation.

User Impact

A valid current writer can persist native usage after a session entry is replaced, even when the retained replica and the database decode insert identical fields in a different order. Replaced writers still cannot finalize usage. No schema, configuration, retention, or permission changes.

Why This Change Was Made

Three contracts were traced to their original changes:

This removes the whole-entry serialization and separate cold-field ordering workaround: production +12/−28, net −16 lines. The smaller comparator still checks every non-participant field. It also subsumes #184372's separate hydrated-owner comparison; that PR's owner-reassignment regression remains unchanged. This is a correctness repair, not a performance claim; allocation/CPU and whole-Gateway stress measurements are not used as evidence.

Credit: the automatic-primary regression was contributed by @obviyus in #148167; the subsequent compatibility, wake recovery, replica preparation, and native-usage contracts were authored by @steipete in the linked PRs.

Evidence

Baseline 2499f2be3e88e025735268fb622e569d69fcd369 reproduces all four reported failing assertions: model metadata, interrupted predecessor order, and both native-usage writers. A new store-boundary regression also fails on the original comparator after two asynchronous replacements followed by a callback patch.

Local validation: 313 tests pass across the complete model-switch (109), shared-run integration (156), entry-revalidation (21), and entry-patch (27) files. The infra shard took 372.66 s; the final entry-patch file took 27.50 s (32.88 s including wrapper). A final red control restored only the original comparator and reproduced session-entry.patch in the committed regression (36.13 s). Changed-file oxfmt, production/test oxlint, and git diff --check pass.

The complete requester-wake E2E file passed five consecutive runs of 39 tests each, with OPENCLAW_E2E_SKIP_BUILD=1 and one worker. Durations: 100.88, 71.45, 67.68, 63.36, and 63.62 s. No retries, timeout increases, or assertion relaxation. These full-file runs preceded the latest-main integration. Ordinary PR CI selects the wake and session-patch regression files. Its bounded planner omitted the unchanged model-switch and shared-run integration files on both submitted heads, so their full-file results above are local evidence, not a claim of direct CI coverage. No CI reruns.

Independent subagent review (autoreview route unavailable): the configured-route preflight refused before inference; configuration was left unchanged. A fresh reviewer received only the diff and relevant contract/owner context and found no actionable P0–P2 findings.

Main integration

ClawSweeper identified a real merge conflict with #184372, without identifying an introduced code defect. Integrated main through 745e1f6f21fd; the resulting comparator is byte-for-byte identical to the independently reviewed candidate and preserves the upstream owner-reassignment coverage. The committed delivery-order regression still fails with that main comparator (session-entry.patch, 56.76 s), proving the residual after the owner-specific repair. Independent review of the resolution found no actionable findings. ClawSweeper also re-reviewed exact head 68316392beaea722665618d4b646a13528bcc57f with no findings and no before-merge items. Post-integration validation passed all 38 tests in the complete entry-patch and entry-patch.operations files (69.90 s), plus both native-usage finalization cases (41.49 s). The prior head 0891758d2ce60d7d87c5963aea9861668d7edfda passed CI; submitted head 68316392beaea722665618d4b646a13528bcc57f passed exact-head CI, including openclaw/ci-gate, all selected test/type/lint checks, the artifact build, and all three PostgreSQL conformance shards. No CI reruns or inherited-failure exceptions were needed.

Direct exact-head job logs confirm 39/39 requester-wake tests and 27/27 session-entry-patch tests. The unchanged model-switch, shared-run integration, and upstream owner-reassignment files were not selected by ordinary PR CI; their focused local results are reported above. No shipped Gateway run or performance measurement is claimed.

The PR is intentionally left ready and unmerged for the coordinating maintainer.

@clawsweeper

clawsweeper Bot commented Oct 26, 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 marked this pull request as ready for review October 26, 2026 08:59
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T09:32:54.282901Z 0891758 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: S labels Oct 26, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 26, 2026
@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR ignores top-level session-field order during comparison and updates the restored-wake test to match recovery-owned reservation ordering.

Example: After two asynchronous session-entry replacements, the current writer persists totalTokens: 13357.

  • Before: Identical fields in different insertion orders cause a session-entry.patch conflict.
  • After: The patch succeeds while changed field values and owner reassignment still cause conflicts.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported repair with meaningful boundary regressions; supplied current-change validation remains harness-based and exact-head CI is pending.
Proof confidence 🦐 gold shrimp (3/6) The ordinary contributor proof gate is inapplicable to this maintainer-authored PR; reported red/green validation exercises the real store owner, and the existing native-usage harness substitutes only the provider attempt.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A current writer can have valid native usage rejected because equivalent retained and decoded session entries enumerate fields differently.
Reason: This maintainer-directed repair restores intended persistence behavior through the existing owner and aligns a test with an already accepted recovery contract.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current session-entry comparison defect and preserves the intended recovery ordering; no actionable introduced defect was found.

Priority: P2
Reviewed head: 68316392beaea722665618d4b646a13528bcc57f

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No current-head shipped Gateway run is supplied for native usage finalization after two asynchronous entry replacements.
Agent review details

How this fits together

Session patch preparation borrows retained entry facts, then the worker compares them with authoritative SQLite state before committing and publishing the result.

flowchart TD
  A[Session patch caller] --> B[Retained entry facts]
  B --> C[Callback patch preparation]
  C --> D[Worker transaction]
  E[Current SQLite entry] --> D
  D --> F[Logical field comparison]
  F --> G[Commit and publication]
Loading

Technical review

Best possible solution:

Keep the shared comparator independent of top-level insertion order while preserving value conflicts, participant exclusions, and existing recovery ownership.

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

Source inspection shows replica delta application preserves existing property positions while main compares the remaining entry through whole-object serialization; the PR reports a matching red-on-base store regression, but this review executed no tests.

Is this the best way to solve the issue?

The focused fix belongs in the existing shared comparison owner and removes the special ordering workarounds without weakening comparisons of owner or content values.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Logical session comparison and participant exclusion keeps the original intent (55ce95f: Separately mutable participant presentation must not invalidate logical-session CAS.)
  • Hydrated cold-field and owner ordering keeps the original intent (perf(worktrees): overlap prompt preparation with index finalization #184372: Hydration may append separately stored fields in different top-level positions; their values remain part of conflict detection.)
  • Restored interrupted-announcement ordering keeps the original intent (d576313: Interrupted recovery reserves announcements after reconciliation so unprepared historical deliveries cannot block ready requester work.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 55ce95f adds src/config/sessions/session-accessor.sqlite-entry-equality.ts:3 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 55ce95fac803; files: src/config/sessions/session-accessor.sqlite-entry-equality.ts)
  • Finn763: Raw commit 10f9b5a adds src/config/sessions/session-accessor.sqlite-entry-equality.ts:4 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 10f9b5a139bf; files: src/config/sessions/session-accessor.sqlite-entry-equality.ts)

PR surface

Source -16, Tests +18, Docs +2. Total +4 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 12 28 -16
Tests 2 22 4 +18
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 36 32 +4

Review metrics

Metric Value Why it matters
Production versus test delta Production +12/-28; tests and test support +22/-4 The production reduction removes field-specific ordering workarounds; test growth adds a store-boundary regression and preserves distinct restored-wake cases.

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: A focused current-main session-persistence defect can reject valid usage finalization, with no evidence of a broader outage.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-26T09:16:25.942Z sha 0891758 :: needs changes before merge. :: none

Reviewed October 26, 2026, 5:36 AM ET / 09:36 UTC (Revision 2).

Compare logical session fields independently of replica insertion order while preserving JSON omission semantics and real conflict detection. Align restored interrupted wake ordering with recovery-owned reservation; retain the exact model capability contract. Reproduced all reported main failures and proved the store regression red on the original comparator.
@steipete
steipete force-pushed the steipete/fix-main-reds-model-switch-wake-usage-20261026 branch from 0891758 to 6831639 Compare October 26, 2026 09:31
@steipete

Copy link
Copy Markdown
Contributor Author

Integrated #184372 through main 745e1f6; submitted head is 6831639. The generic field comparator is unchanged from the reviewed candidate and subsumes the upstream owner-specific comparison. Its regression proving changed owners still conflict remains intact.

The delivery-order regression still fails against current main. After integration, all 38 session-entry patch tests and both native-usage finalization cases passed locally. The prior-head CI passed; the new exact-head CI is running. The PR body now records the integration, proof, and net 16-line production deletion. Independent review of the conflict resolution found no actionable findings.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 26, 2026
@steipete
steipete merged commit 6f94c2a into main Oct 26, 2026
146 of 148 checks passed
@steipete
steipete deleted the steipete/fix-main-reds-model-switch-wake-usage-20261026 branch October 26, 2026 09:59
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
…aw#184427)

Compare logical session fields independently of replica insertion order while preserving JSON omission semantics and real conflict detection. Align restored interrupted wake ordering with recovery-owned reservation; retain the exact model capability contract. Reproduced all reported main failures and proved the store regression red on the original comparator.
RomneyDa added a commit that referenced this pull request Oct 28, 2026
Compare logical session fields independently of replica insertion order while preserving JSON omission semantics and real conflict detection. Align restored interrupted wake ordering with recovery-owned reservation; retain the exact model capability contract. Reproduced all reported main failures and proved the store regression red on the original comparator.

(cherry picked from commit 6f94c2a)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit afafabf831c462415dbac05526eeef1c18be736b)
RomneyDa added a commit that referenced this pull request Oct 28, 2026
Compare logical session fields independently of replica insertion order while preserving JSON omission semantics and real conflict detection. Align restored interrupted wake ordering with recovery-owned reservation; retain the exact model capability contract. Reproduced all reported main failures and proved the store regression red on the original comparator.

Beta.5 baseline adaptation: Retain the native beta.5 owners, fixtures and public contracts; add focused regression controls and bounded fixture extraction; apply checkout formatting.

(cherry picked from commit 6f94c2a)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 78cb890169c01edca2b7fd719b939402f76368a4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S 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