Skip to content

Bound the OpenCode Go Auto history scan - #5062

Open
harjothkhara wants to merge 2 commits into
steipete:mainfrom
harjothkhara:issue-5060-opencodego-auto-budget
Open

harjothkhara wants to merge 2 commits into
steipete:mainfrom
harjothkhara:issue-5060-opencodego-auto-budget

Conversation

@harjothkhara

Copy link
Copy Markdown
Contributor

Fixes #5060.

In Auto, OpenCode Go finished the whole local opencode.db scan before asking for remote quota, so a cold run on a large or slow database blocked for tens of seconds. Auto now joins the local scan for at most 5 s, using the existing BoundedTaskJoin.

  • A remote source gives authoritative quota (API key, browser or CLI login): it's returned right away, with no partial history.
  • No remote source does: the refresh keeps waiting on the same scan and returns the local estimate, as before.
  • Cancelling the refresh stops the wait but not the scan, which keeps warming the in-process cache.
  • web, api and cli sources are unchanged.

Tests: OpenCodeGoAutoScanBudgetTests covers a slow scan with remote quota (prompt return), a slow scan without remote quota (local result) and a small database (unchanged). I ran it and the existing OpenCode Go suites (94 tests) in a Core-only target, plus mutation checks, because the full test target needs Xcode here. make check passes.

Release CodexBarCLI, usage --provider opencodego --source auto --format json, synthetic database in a scratch home with network and Keychain denied:

  • 3 GB, no credentials: base returned local usage after ~20 s, and so did this head (~38 s for both on the 2.6 GB rerun).
  • 70 MB: identical output.
  • Prompt remote return: covered by tests only, because OpenCode Go has no configurable base URL to stub.

🤖 Generated with Claude Code

harjothkhara and others added 2 commits November 11, 2026 08:43
Auto waits at most 5 seconds for local history before returning
authoritative remote quota without history. The scan keeps running to
warm the reader cache for a later refresh; partial history is never
published.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the bounded Auto scan times out and no API key, browser session,
or CLI login yields authoritative quota, wait for the same scan and
return the local estimate as before instead of failing. The wait stays
cancellable and never cancels the scan itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

🦞👀
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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T17:35:49.825701Z 87acf7e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 11, 2026
@clawsweeper

clawsweeper Bot commented Nov 11, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge.

What this changes

This PR limits Auto’s initial local-history wait to five seconds before trying authoritative remote quota, while preserving local-only fallback.

Example: A 488 MB OpenCode database takes 30 seconds to scan, while the CLI login can return quota in under one second.

  • Before: Auto waits for the full local scan before requesting quota.
  • After: Auto requests remote quota after five seconds and can return it without daily history while the scan continues.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation is focused and no definite correctness defect was found, but the central changed behavior lacks shipped-entry-point proof and the output tradeoff awaits an owner decision.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: OpenCode Go Auto can leave quota refreshing for tens of seconds while reading local history even when remote quota is readily available.
Reason: The latency improvement has clear value, but temporarily dropping daily history and selecting a five-second budget change the existing output contract.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR addresses a current cold-scan delay and contains no definite introduced defect found in review; the bounded wait and omission of slow history need an owner decision.

Priority: P2
Reviewed head: 87acf7e39a0f83d3cbecb0221fe12e1c2cce96ff
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should Auto return authoritative quota after a five-second history wait, temporarily omitting daily history from that refresh?
  • Recommendation: Accept the bounded history wait: Approve the five-second budget and remote-only result for slow scans, with complete history available on later refreshes.
  • Why: This changes the existing history-preservation behavior and introduces a fixed wait budget; prior owner work establishes the current contract, but no owner has approved this specific tradeoff.

Before merge

  • Add real behavior proof - The supplied release-CLI results exercise synthetic large databases without credentials and establish preserved local fallback; prompt authoritative return uses a stubbed quota fetcher in tests only. Supply redacted terminal output or a recording of the real CLI with a slow scan and working remote quota, including elapsed return and omitted unfinished history, plus cancellation behavior; redact IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.

Findings

None.

Tests

  • Missing end-to-end proof: Show the shipped CLI returning authoritative quota before a slow scan completes, then show a later same-process refresh retaining history; base-fail/head-pass regression output was not supplied.
Agent review details

How this fits together

The OpenCode Go provider receives source and account settings, combines SQLite cost history with authenticated quota sources, and returns usage snapshots to the app and CLI.

flowchart TD
A[App or CLI refresh] --> B[OpenCode Go Auto strategy]
B --> C[Local SQLite scan]
C --> D[Bounded history join]
D --> E[Existing remote quota sources]
E --> F[Usage snapshot]
E --> G[Await same scan without quota]
G --> F
Loading

Technical review

Best possible solution:

Keep the existing provider and cache owners, bound only Auto’s history join, and preserve authoritative quota precedence and complete local fallback.

Do we have a high-confidence way to reproduce the issue?

Current-main source serializes the full SQLite history read before quota overlays, matching the linked v0.84.0 report and its SQLite I/O trace; no target code was run during this read-only review.

Is this the best way to solve the issue?

The patch addresses the blocking dependency in the existing strategy and reuses the shared join helper while retaining account-selection guards and local fallback.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 7447bc77c249.

Provenance checked

  • Local-first Auto and scoped source ordering changes intended behavior with a stated reason (Prefer OpenCode Go local usage in Auto mode #2316: Avoid slow web sessions delaying usable local results while preserving explicit account and workspace scope.)
  • Authoritative overlays with retained local history changes intended behavior with a stated reason (cf7b749: Replace misleading locally inferred quota windows with server values while retaining daily costs; CLI quota support later preserved that contract.)
  • Estimated quota and balance-only fallback keeps the original intent (ef1cb92: Distinguish device-local estimates from authoritative quota and avoid treating balance-only enrichment as quota confirmation.)
  • Bounded in-process history caching keeps the original intent (79b212d: Reuse unchanged scans with bounded retention and database/WAL invalidation.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 79b212d adds Sources/CodexBarCore/Providers/OpenCodeGo/OpenCodeGoProviderDescriptor.swift:175 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 79b212d35bad; files: Sources/CodexBarCore/Providers/OpenCodeGo/OpenCodeGoProviderDescriptor.swift)
  • sreejithraman: Raw commit 7791445 adds Sources/CodexBarCore/Providers/OpenCodeGo/OpenCodeGoProviderDescriptor.swift:180 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 77914457d3bf; files: Sources/CodexBarCore/Providers/OpenCodeGo/OpenCodeGoProviderDescriptor.swift)
  • kiranmagic7: Raw commit 828aebf adds Sources/CodexBarCore/Providers/OpenCodeGo/OpenCodeGoProviderDescriptor.swift:52 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 828aebff9130; files: Sources/CodexBarCore/Providers/OpenCodeGo/OpenCodeGoProviderDescriptor.swift)

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production and test delta Production +88/-6; tests +261; documentation +5 Production changes stay in the existing strategy and reuse BoundedTaskJoin; tests exercise timeout, cache reuse, local fallback, and cancellation.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #5060
Summary: This PR targets the cold-scan dependency reported by the canonical issue; earlier cache work improves repeated reads rather than removing that dependency.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add P2: The delay affects OpenCode Go Auto refreshes with large or slow databases; explicit API mode provides a documented working workaround.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: The delay affects OpenCode Go Auto refreshes with large or slow databases; explicit API mode provides a documented working workaround.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

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

  • Demonstrate the remote-return and cancellation paths through the shipped CLI.
  • Obtain an owner decision on the five-second budget and temporary omission of daily history.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 11, 2026, 12:41 PM ET / 17:41 UTC.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenCode Go auto hangs on large opencode.db — initial scan is unbounded (488 MB)

1 participant