Skip to content
Source
Sign inSign up
pingdotgg/t3code

refactor(usage): OpenCode usage comes from provider-opencode #17577

Mergedjuliusmarmingemerged 1 commit intot3/usage-transcript-readers fromrefs/pull/17577/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

The OpenCode usage reader and its OPENCODE_DATA_DIR/XDG root resolution lived in apps/server.

They move into provider-opencode as a scan reader on OpenCodeDriver.usage. UsageService runs scan readers generically and fills in a source's volume id from its directory when a reader leaves it out. Tests move with the code.

🤖 Generated with Claude Code (Claude Opus 5.5, Claude Code harness)

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. juliusmarminge added labelsmacroscope-review

    3. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire—5.0 KiB—6.8 KiB✅
      CodexThread snapshot wire—3.8 KiB—4.9 KiB✅
      CodexLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
      CodexLive turn WebSocket decoded—20.9 KiB—29.3 KiB✅
      CodexLive turn messages—2—8✅
      ClaudeTotal thread wire—5.0 KiB—6.8 KiB✅
      ClaudeThread snapshot wire—3.8 KiB—4.9 KiB✅
      ClaudeLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
      ClaudeLive turn WebSocket decoded—21.2 KiB—29.3 KiB✅
      ClaudeLive turn messages—1—8✅

      Baseline: unavailable · PR result: 0d411e3 · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This is primarily a behavior-preserving refactor that relocates OpenCode usage scanning into its provider package and adds generic scan plumbing. The new test file also adds a file-level static-analysis suppression directive, requiring human review.

      No code changes detected at 0d411e3. Prior analysis still applies.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Team
      • Run ID: 1d3ba86e-6648-4465-97a6-8dfd3ffc9294

      📥 Commits

      Reviewing files that changed from the base of the PR and between a97390980eac1a5d21ed9ec0191c44c7e77879f1 and 0d411e3eb0a265e1b93ed95a942311ef37169fad.


      📒 Files selected for processing (2)
      • apps/server/src/usage/UsageService.ts
      • packages/provider-core/src/server/usage.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.



      📝 Walkthrough

      Walkthrough

      OpenCode usage history is now read through a provider scan reader registered as a built-in usage driver. UsageService runs built-in scan readers alongside its other usage sources. The scan result contract allows readers to omit a volume ID.

      Changes

      OpenCode usage scanning

      Layer / File(s)Summary
      OpenCode scan reader and contract
      packages/provider-core/src/server/usage.ts, packages/provider-opencode/src/server/usage.ts, packages/provider-opencode/src/server/usage.test.ts, apps/server/src/usage/usageTranscriptReader.test.ts
      The scan contract makes volumeId optional. The OpenCode reader resolves and deduplicates data roots, scans them, and reports missing or partially readable history. Tests for SQLite and legacy JSON history are now in the OpenCode package; the corresponding test was removed from the server transcript-reader suite.
      Register OpenCode scan reader
      packages/provider-opencode/src/server/driver.ts, apps/server/src/provider/builtInDrivers.ts
      OpenCodeDriver exposes openCodeUsageReader and is included in the built-in usage driver list.
      Run scan readers during usage collection
      apps/server/src/usage/UsageService.ts
      UsageService selects built-in scan readers, supplies configured instances and scan cutoffs, normalizes returned sources, and includes them in collection. The dedicated OpenCode collection path was removed.

      Priority: ⬇️ Low

      Estimated code review effort: 3 (Moderate) | ~20 minutes

      Change: Refactor

      Sequence Diagram(s)

      sequenceDiagram
        participant UsageService
        participant OpenCodeDriver
        participant openCodeUsageReader
        participant FileSystem
        UsageService->>OpenCodeDriver: select built-in scan reader
        UsageService->>openCodeUsageReader: provide instances and scan cutoffs
        openCodeUsageReader->>FileSystem: resolve roots and read usage history
        FileSystem-->>openCodeUsageReader: history results
        openCodeUsageReader-->>UsageService: scanned sources and status

      Suggested reviewers: t3dotgg


      Merge Risk: ⚪ Minimal · up to 0d411

      No actionable OpenCode usage regression was established; this PR is mergeable after normal checks.

      Pre-merge checks | Passed 3 | Failed 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Description checkWarningThe description explains the code movement and generic scan-reader change, but it omits the required Problem, Scope and approval, and Verification sections. It provides no test results or statement of…Add the required Problem, Change, Scope and approval, and Verification sections. Include the problem and expected behavior, issue or maintainer approval details, focused tests with observed results, and any checks that were not run.
      ✅ Passed checks (3 passed)
      Check nameStatusExplanation
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Title checkPassedThe title clearly identifies the main change: moving OpenCode usage handling into provider-opencode. It is concise and specific.

      Full details: Description check

      Explanation

      The description explains the code movement and generic scan-reader change, but it omits the required Problem, Scope and approval, and Verification sections. It provides no test results or statement of unchecked items.



      • Fix all pre-merge checks with AI
      ✨ Finishing Touches 💡 1
      🛠️ Fix failing CI checks 💡
      • Commit to this branch
      • Create a new PR

      📝 Generate docstrings
      • Commit to this branch
      • Create a new PR

      🧪 Generate unit tests (beta)
      • Commit to this branch
      • Create a new PR


      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Comment `@coderabbitai help` to get the list of available commands.
    6. juliusmarminge merged this23957c7

    7. juliusmarminge closed this

Sign in to join this conversation.