Repository navigation
fix(gateway): retain CLI metadata after history dedupe - #130494
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed September 8, 2026, 5:30 PM ET / 21:30 UTC (Revision 7). ClawSweeper reviewWhat this changesPreserves Claude CLI session metadata on deduplicated chat messages while maintaining transcript order, anchored reads, and offset pagination. Merge readiness✅ Ready for maintainer review This remains a useful fix: current main and v2026.9.3 still discard metadata-only imports. The latest commit resolves the previous duplicate-row finding, and no remaining blocking correctness defect was established. Priority: P2 Review scores
Verification
How this fits togetherGateway chat history combines OpenClaw’s stored messages with the bound Claude CLI transcript. Deduplication selects the visible messages, then display projection and pagination prepare responses for history consumers. flowchart LR
A[Stored OpenClaw messages] --> C[History merge]
B[Bound Claude transcript] --> C
C --> D{Matching local message?}
D -->|Yes| E[Retain local content and native metadata]
D -->|No| F[Include imported message]
E --> G[Display projection and pagination]
F --> G
G --> H[Chat history response]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +433, Tests +826. Total +1259 across 7 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep identity enrichment in the history merge owner and preserve local content, transcript order, and established paging behavior. Do we have a high-confidence way to reproduce the issue? Yes, from source: matching local and imported messages are deduplicated on current main without transferring native identity, and unchanged row count causes the resolver to discard metadata-only results. This review did not execute a reproduction. Is this the best way to solve the issue? Yes. Repairing the merge owner and distinguishing metadata incorporation from added rows addresses the defect without synthesizing downstream IDs or changing stored schemas. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1d2cdf26138f. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
…on-metadata # Conflicts: # src/gateway/cli-session-history.merge.ts
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
* fix(gateway): retain CLI metadata after history dedupe * fix(gateway): preserve CLI history metadata * fix(gateway): harden CLI history deduplication * fix(gateway): preserve CLI history paging invariants * fix(gateway): preserve CLI history identity order * fix(gateway): preserve CLI history match ordering * fix(gateway): preserve CLI match order across candidate pools * fix(gateway): keep CLI match floors monotonic * fix(gateway): retain deferred CLI history matches * fix(gateway): preserve local matches after imports
What Problem This Solves
Fixes #130456. Claude native-history rows that exactly matched local rows were deduplicated without transferring their import provenance, so
chat.historylost the bound CLI session ID.Why This Change Was Made
The history merge owner now preserves validated native identity metadata on the surviving local row and reports incorporation correctly across paginated history. It does not synthesize IDs downstream, duplicate visible messages, or change persistence schemas.
Repeated-text matching preserves transcript-order identity assignment without assuming timestamps are chronological. A timestamp index retains eligible candidates behind future-dated rows and across timestamp-less fallbacks; consumed rows cannot be reused.
User Impact
CLI-backed sessions retain native session identity after local/native history deduplication, so resume and history consumers can continue using the authoritative Claude session metadata.
Evidence
f1f34f3a6cbf: two local rows with timestamps[600000, 0]and one matching import incorrectly produced three visible rows. The repaired candidate returns two rows and preserves the imported identity on the matching survivor.4b17af97b545be1811ae04ff3da6febb2105bfc0: 231 focused CLI history/Gateway tests passed; requiredcheck:changedpassed; formatting and diff checks passed.INDEX-onlyand confirmed the working-tree repair was correct; staging the reviewed files resolved it before commit.