Repository navigation
refactor(usage): remove legacy session locators - #163182
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: needs changes before merge. Reviewed October 2, 2026, 1:50 AM ET / 05:50 UTC (Revision 5). ClawSweeper reviewWhat this changesUsage reports replace historical session-file overrides with explicit transcript artifacts or validated canonical session targets, and refresh visibility metadata through existing worker readers. Merge readiness⛔ Needs changes before merge - 1 item remains The cleanup remains useful on current main. Earlier findings are resolved, and verified hosted boundary checks satisfy the scoped authority proof requirement. Likely related people: steipete (high-confidence routing candidate). Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s usage subsystem reads session metadata and retained transcripts to produce cost summaries, charts, logs, and status text. Gateway selection binds these reads to the requested session and its visibility rules. flowchart TD
A[Usage request] --> B[Select session owner]
B --> C[Worker metadata read]
C --> D[Validate identity and visibility]
D --> E[Canonical SQLite transcript]
B --> F[Explicit retained artifact]
E --> G[Usage report]
F --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource -15, Tests +122, Other -1. Total +106 across 14 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep usage selection with the existing canonical session and worker-read owners while preserving explicit retained-artifact reads. Do we have a high-confidence way to reproduce the issue? Yes, source establishes that current main can let historical metadata override an explicit artifact. The hosted original-base negative control independently verifies that mechanism; this review did not execute current main. Is this the best way to solve the issue? Yes, the patch removes competing locator readers and reuses existing worker ownership instead of adding another compatibility path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a272cf0cd56e. 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
HistoryReview history (4 earlier review cycles)
|
* refactor(usage): read canonical session sources with current visibility * test(usage): keep authoritative lineage fixtures consistent * chore(usage): remove obsolete max-lines suppression
…upstream openclaw#163182, openclaw#164103) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Jhynq2GVpzuVQQieebEubg
Three fork-only test copies still asserted contracts upstream changed: - usage.sessions-usage-details: openclaw#163182 usage target (red since before the absorb) - provider-catalog-live-runtime.config: stale split of upstream's rewritten test (openclaw#167462, step 11) - user-turn-transcript.recorder: openclaw#168394 keeps the admission generation (step 20) Test files only. GREEN/RED/GREEN, neighbours and static gates recorded in the lane's .lane/DONE. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Jhynq2GVpzuVQQieebEubg
What Problem This Solves
Usage lookup could let a historical
sessionEntry.sessionFileoverride an explicitly selected artifact. Removing that cast alone would leave a second compatibility reader in path derivation. Both readers now disappear: usage consumes an explicit artifact or a complete canonical session target.Canonical target validation and Gateway target selection use the existing worker read owners. The final worker entry and selected source are returned together, so visibility checks do not reuse an older snapshot after validation yields. The selected physical store is carried forward, stale key/session pairs are rejected, read failures remain failures, and captured cancellation is checked across the new awaits. A retained transcript may still outlive its metadata row. Existing JSONL/archive artifacts remain readable; malformed partial targets no longer borrow missing fields from another locator. Status cost reads select their canonical SQLite owner through the existing physical-store resolver.
This is derived usage projection cleanup. It does not rewrite or delete persisted state and needs no migration. Updates continue using canonical session targets and explicit retained artifacts; obsolete metadata no longer redirects usage reads.
Production (
src/**andextensions/**, excluding tests/support): +131/-146/net -15. Seven production files changed; no new generic API or database schema.Overlap: draft #161513 narrows assertions in the same resolver; #157922 changes transcript discovery/event-time behavior in the same file. This change preserves those discovery paths and will rebase if needed.
Evidence
Final head:
32d259b99c057881d465a56459e66d4a94ea5e82. Exact-head normal CI passed, including changed tests, production/test types, lint, baseline ratchets, build, and security checks. Independent Codex reviews through P2 are clean, including the fixture correction and final suppression cleanup.oxfmtandgit diff --checkpassed.After repeated Testbox admission failures without a runner, the coordinator-authorized hosted fallback passed both attributable negative controls and all 69 tests in six focused suites. That job's independent Npm update cell failed; the Usage step and its uploaded
usage/summary.jsonpassed. No local tests or builds ran and this fallback uses no persistent lease.Behavior proof is pinned to
3a99184788fe3afd11f40ed75d909773f8c5fa11. The final head only removes an obsolete lint-suppression comment and its grandfathered baseline entry; executable behavior and tests are identical. Negative controls fail at the intended assertions: the original reader overrides an explicit artifact, and the pre-fence implementation reaches the summary loader after usage-context revocation.Each focused command was
pnpm test <file> --maxWorkers=1on the GitHub-hosted runner:src/infra/session-cost-usage.test.tssrc/infra/session-cost-usage.archive-identity.test.tssrc/gateway/server-methods/usage.sessions-usage.test.tssrc/gateway/server-methods/usage.sessions-usage-context-lifecycle.integration.test.tssrc/gateway/server-methods/usage.sessions-usage-owner-attribution.integration.test.tssrc/status/status-text.test.tsThe complete hosted Usage step took 507 seconds, including three frozen installs and both controls. The controls took 36.46s and 47.41s. These are full command/CI costs, not isolated assertion durations.
The first CI run caught a deterministic fixture mismatch: the combined-store mock supplied family IDs omitted by the authoritative read mock. Both now use the same typed entry; all rollup assertions remain. The canonical-source case moved into the existing archive-identity suite and gained a real-worker lineage assertion. This introduced no extra test process, sleep, timeout increase, or weaker assertion. The exact assertion baseline shrank from three to two; a subsequent obsolete max-lines suppression and its baseline entry were removed.
Existing JSONL/archive artifacts remain readable, including rowless retained transcripts. The unrelated combined-store/context and transcript readers retain their existing execution owners; this PR does not claim all usage processing is free of synchronous SQLite. The lifecycle regression protects revocation before the final target read, not every pre-existing authorization window.