Skip to content

refactor(usage): remove legacy session locators - #163182

Merged
steipete merged 3 commits into
mainfrom
fix/lg-runtime-usage-canonical
Oct 2, 2026
Merged

steipete merged 3 commits into
mainfrom
fix/lg-runtime-usage-canonical

Conversation

@steipete

@steipete steipete commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Usage lookup could let a historical sessionEntry.sessionFile override 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/** and extensions/**, 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. oxfmt and git diff --check passed.

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.json passed. 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=1 on the GitHub-hosted runner:

File Passed Wall seconds
src/infra/session-cost-usage.test.ts 25 45.89
src/infra/session-cost-usage.archive-identity.test.ts 10 61.93
src/gateway/server-methods/usage.sessions-usage.test.ts 10 41.02
src/gateway/server-methods/usage.sessions-usage-context-lifecycle.integration.test.ts 3 51.22
src/gateway/server-methods/usage.sessions-usage-owner-attribution.integration.test.ts 9 60.68
src/status/status-text.test.ts 12 48.41

The 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.

@clawsweeper

clawsweeper Bot commented Oct 2, 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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M labels Oct 2, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 2, 2026
@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed October 2, 2026, 1:50 AM ET / 05:50 UTC (Revision 5).

ClawSweeper review

What this changes

Usage 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
Reviewed head: 32d259b99c057881d465a56459e66d4a94ea5e82

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused ownership cleanup and verified boundary execution provide normal good patch confidence; required test-cost reporting remains incomplete in the captured body.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (linked_artifact): The verified hosted production-path harness exercises Gateway usage selection with real persistence and the actual worker reader, successful viewer responses, and persisted same-session revocation denied before summary loading. Intended-failure negative controls passed, and final-head changes leave executable behavior unchanged. Raw logs were inaccessible to this reviewer; no stored-data contract changes require migration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The verified hosted production-path harness exercises Gateway usage selection with real persistence and the actual worker reader, successful viewer responses, and persisted same-session revocation denied before summary loading. Intended-failure negative controls passed, and final-head changes leave executable behavior unchanged. Raw logs were inaccessible to this reviewer; no stored-data contract changes require migration.
Evidence reviewed 9 items Introduced production changes: The pinned introduction removes metadata-based locator precedence, validates complete targets through the existing worker reader, and carries refreshed entries into Gateway visibility checks. No schema, dependency, permission configuration, or plugin SDK changes are introduced.
Current main still needs the change: Fetched main retains resolveExistingUsageSessionFile and chooses matchingEntryMarker before matchingExplicitMarker. The central cleanup is therefore not already implemented there.
Latest release retains legacy precedence: The v2026.9.7 source still selects matchingEntryMarker before matchingExplicitMarker; no release implementation supersedes this PR.
Findings None None.
Security None None.

How this fits together

OpenClaw’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
Loading

Before merge

  • Complete next step (P2) - Add the measured focused-suite wall times and CI costs from the completed hosted usage step to the PR body; reuse the existing run.
Agent review details

Security

None.

PR surface

Source -15, Tests +122, Other -1. Total +106 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 7 131 146 -15
Tests 5 207 85 +122
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 1 2 -1
Total 14 339 233 +106

Review metrics

Metric Value Why it matters
Production versus test growth production +131/-146, net -15; tests +207/-85, net +122 Production shrinks while added coverage protects artifact precedence, worker ownership, lineage, and revocation boundaries.

Technical review

Best 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.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The verified hosted production-path harness exercises Gateway usage selection with real persistence and the actual worker reader, successful viewer responses, and persisted same-session revocation denied before summary loading. Intended-failure negative controls passed, and final-head changes leave executable behavior unchanged. Raw logs were inaccessible to this reviewer; no stored-data contract changes require migration.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The verified hosted production-path harness exercises Gateway usage selection with real persistence and the actual worker reader, successful viewer responses, and persisted same-session revocation denied before summary loading. Intended-failure negative controls passed, and final-head changes leave executable behavior unchanged. Raw logs were inaccessible to this reviewer; no stored-data contract changes require migration.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 security-boundary: Current PR review selected no merge-risk labels.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a bounded usage-selection improvement with meaningful identity and visibility coverage, without evidence of an urgent current outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The verified hosted production-path harness exercises Gateway usage selection with real persistence and the actual worker reader, successful viewer responses, and persisted same-session revocation denied before summary loading. Intended-failure negative controls passed, and final-head changes leave executable behavior unchanged. Raw logs were inaccessible to this reviewer; no stored-data contract changes require migration.
  • proof: sufficient: Contributor real behavior proof is sufficient. The verified hosted production-path harness exercises Gateway usage selection with real persistence and the actual worker reader, successful viewer responses, and persisted same-session revocation denied before summary loading. Intended-failure negative controls passed, and final-head changes leave executable behavior unchanged. Raw logs were inaccessible to this reviewer; no stored-data contract changes require migration.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record the measured focused-suite wall times and CI costs from the existing hosted evidence in the PR body.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-02T02:47:11.229Z sha aa0183d :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-02T04:42:11.975Z sha aa0183d :: needs real behavior proof before merge. :: [P2] Preserve family lineage in the migrated worker fixture | [P3] Extract resolver coverage from the over-cap test file
  • reviewed 2026-10-02T05:09:13.276Z sha 3a99184 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-02T05:40:47.412Z sha 32d259b :: needs real behavior proof before merge. :: none

@steipete
steipete marked this pull request as ready for review October 2, 2026 04:35
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 2, 2026
@steipete
steipete merged commit ab0f173 into main Oct 2, 2026
151 checks passed
@steipete
steipete deleted the fix/lg-runtime-usage-canonical branch October 2, 2026 06:17
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 3, 2026
* refactor(usage): read canonical session sources with current visibility

* test(usage): keep authoritative lineage fixtures consistent

* chore(usage): remove obsolete max-lines suppression
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 15, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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