Repository navigation
refactor(sessions): centralize history reply validation - #157240
vincentkoc wants to merge 1 commit into
Conversation
|
🦞👀 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: blocked before merge. Reviewed October 1, 2026, 9:15 AM ET / 13:15 UTC (Revision 4). ClawSweeper reviewWhat this changesThe branch centralizes session-history reply validation and adds tests for reader projections, invalid replies, cancellation forwarding, captured inputs, and worker retirement. Merge readiness⛔ Blocked before merge - 2 items remain Keep open: current main covers the production consolidation, but distinct reader and retirement tests remain. The maintainer-authored draft is not fully superseded, and no introduced correctness defect was found. Priority: P3 Review scores
Verification
How this fits togetherSession-history readers turn worker replies into conversation data for OpenClaw callers. The enclosing runtime owns database access, cancellation, and worker cleanup when decoding fails. flowchart TD
A[History request] --> B[Reader prepares request]
B --> C[Database worker]
C --> D[Validate reply kind]
D --> E[Return conversation data]
D --> F[Await worker retirement]
F --> G[Report decoding error]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -106, Tests +333. Total +227 across 3 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep main's canonical reader implementation and retain useful, nonduplicative decoding and retirement coverage at its existing test boundaries. Do we have a high-confidence way to reproduce the issue? Not applicable: this behavior-preserving refactor reports no product bug; source comparison supports equivalent historical reply decoding. Is this the best way to solve the issue? Yes for the remaining test contribution: adapting it to main's existing owner is the narrowest path. The historical production consolidation is no longer needed. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6010d074f754. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
October 14 Integration Disposition
Retain this draft for selective test integration, not the historical production refactor or a wholesale replay of its 37-case factory suite. Source comparison was pinned to main
9ed9c2cd1744.createSessionHistoryWorkerRequestStubcontract.readRowBackfillandreadUsageCacheare gone; search requiresreadIndexStatus. Preserve paginated entry results and theirsource/factsfields when assessing separate entry-reader cases.Preserve the private test-only candidate and existing writer. Current-main integration, remote regression/runtime proof, actionable review disposition, exact-head CI and native landing qualification remain pending. No source, branch, draft or landing transition is made here; no application tests were run for this comparison.
Retained Earlier Status
The following records the earlier branch and inspected-main state. Its test counts and proofs do not qualify a newly integrated head.
Status: retain the draft for a test-only residual; the production consolidation is already on main. 157146 (
f2e0c54bec175) introduced the shared typed reply assertion, and 159054 (aec71eae8c24) consolidated the reader construction, including historical eviction and entry-read Result replies. Both are verified merged ancestors of inspected main6010d074f754d142ee1134416bcd9a4d5290a3db. The formerly referenced 156541 also merged, but its landed delta did not supply this readers-file replacement.The added 291-line factory suite and mismatched-reply retirement case remain distinct from inspected main; complete supersession is not established. Preserve the current reader owner, lazy captured inputs, paginated entry reads and expanded worker lifecycle. The existing owner should select/adapt useful tests to that owner, without reintroducing the historical production helper. No source, draft, or landing transition is made by this status correction; integrated proof and native qualification remain pending.
What Problem This Solves
This branch originally addressed repeated reply-kind validation in 16 session-history callbacks. That production duplication has since been removed on main; the remaining contribution is distinct reader and retirement coverage.
Maintainer-sponsored refactor: @vincentkoc requested this duplication cleanup and authorized landing.
User Impact
No user-visible behavior change. Reply tags, error messages, return values, lazy request preparation, byte accounting, cancellation, and worker retirement remain unchanged. No config, schema, data migration, or operator action is introduced.
Why This Change Was Made
This branch introduced one private typed assertion for the repeated single-kind check; main now has its own canonical assertion and reader builder. The distinct multi-kind, streamed, array, and boolean decoders retain their existing behavior, including the usage-cache request's
usage-refresh-lockreply.Historical branch delta: production -106 lines; tests +333 lines, covering all 16 public factory mappings, invalid reply shapes, projection identity, request forwarding, and awaited retirement before rejection.
Evidence
The retained evidence below describes the published historical branch, not qualification of a reconstructed test-only residual on current main. This status audit was source-only; no new application tests were run.
Matched one-file duplication and complexity measurements
Same SCB 0.2.0 policy and adapter; only
session-transcript-worker-readers.tswas measured, with one parse per version.Both original high-complexity functions remain above the threshold. Cyclomatic erosion changes from 100% to 98.0973%, partly because the new low-complexity helper contributes denominator mass. Nested callbacks also contribute to their enclosing function, so aggregate complexity totals are not unique branch counts. These are matched one-file maintainability measurements, not a whole-repository score, correctness proof, or runtime claim.