Skip to content

Muse Code: read omitted quotas from dev.meta.ai with an opt-in browser session - #4003

Closed
enieuwy wants to merge 2 commits into
steipete:mainfrom
enieuwy:feat/muse-web-quota-fallback
Closed

enieuwy wants to merge 2 commits into
steipete:mainfrom
enieuwy:feat/muse-web-quota-fallback

Conversation

@enieuwy

@enieuwy enieuwy commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #4002.

While the Muse Code 5-hour window is idle, POST /muse-code/key omits subs_usage, so CodexBar (and the Muse CLI /usage) show no quota even when the weekly limit has real usage. This adds an opt-in fallback inside the existing bundled muse.ts plugin: when — and only when — the login response omits subs_usage, it reads the same quota the dev.meta.ai/usage page shows, using the browser session for the same account.

No new provider, no new plugin-host capability, no browser automation.

Behavior

  1. /muse-code/key still runs first and still wins. If it contains subs_usage, no dev.meta.ai request is made.
  2. Otherwise, if the Muse cookie source is Automatic or Manual:
    • GET /api/auth/me — the session email must equal the CLI login's user_email, or no web quota is used.
    • GET /api/portal/teams, then GET /api/portal/teams/{id}/subscription-quota for at most two teams.
    • 5 hours = window_weighted_used / window_weighted_limit; Weekly = weekly_weighted_used / weekly_weighted_limit, reset weekly_resets_at. An idle window shows 0% with no invented reset time; window_resets_at is used only when present.
    • Result source label oauth+web, dataConfidence: exact.
  3. Any web failure (Off, no session, account mismatch, timeout, non-200, malformed JSON, no team quota) keeps today's result exactly: plan + identity, Quota: Not included in this login response, no bars. 401/403 rejects the cached cookie.

Privacy / safety decisions

  • Cookie source defaults to Off in both the app (SettingsStore.museCookieSource) and CLI (credentialSettings), following Zed's precedent. A pasted header with no explicit source means Manual. Existing installs make no dev.meta.ai request until the user opts in.
  • Automatic reads Chrome and Firefox only ([.chrome, .firefox], like LongCat's explicit order) to avoid Safari Full Disk Access and other Chromium Safe Storage prompts.
  • Credentials stay scoped: the plugin declares no global auth; the dca: device token is sent only to api.meta.ai, the cookie only to dev.meta.ai (same split as huggingface.ts).
  • Account cross-check before using web data, as huggingface.ts does for its cookie profile.
  • Deadline: runtime 60 s; key POST 15 s; ≤4 sequential GETs at 8 s each (≤47 s total, no retry policy).

UI

Muse settings gain the shared ProviderCookieSourceUI.picker (Automatic / Manual / Off, Off allowed), a secure Manual cookie field, and an "Open dev.meta.ai" action — the same wiring as T3 Chat. Existing localized strings are reused.

Proof

.github/pr-proof/muse-web-quota-fallback.log — real account, production CLI path (codexbar usage --provider muse), 2026-09-26 03:22–03:39 AWST, idle 5-hour window:

Build source 5 hours Weekly
Brew 0.66.0 oauth — (Not included in this login response) —
This branch oauth+web 0% 22.58% (endpoint: 13,550,839,000 / 60,000,000,000), resets 2026-09-28T00:00Z
This branch, no cookie source configured oauth — — (Off by default)

With an active window (subs_usage present) both builds returned identical oauth output (6% / 17%). The proof used a temporary MUSE_AUTH_PATH file and a Manual cookie in a temporary CODEXBAR_CONFIG, so no CodexBar Keychain read occurred; both files were deleted afterwards. Token, cookie, email, and tier ID are redacted.

Tests

Tests/CodexBarTests/MusePluginTests.swift, both plugin engines:

  • web fallback fills 5-hour and weekly windows; idle window has no reset
  • no dev.meta.ai request when subs_usage is present
  • account mismatch, Off, 401 rejection, malformed quota, teams without a quota → OAuth-only result
  • the device token never reaches dev.meta.ai
  • browser session access stays off until configured (nil config, empty config, header-only → Manual, explicit Auto)

Existing coverage searched

gh pr/issue list --search for muse, meta.ai, dev.meta.ai, subscription-quota, llama_dev_sess, muse quota; clawsweeper triage labels on the Muse items.

Commands run

  • swift test --filter 'MusePluginTests|MuseCredentialsTests|MuseKeychainAccessTests|ProviderArchitectureGatekeeperTests|ProviderPluginRuntimeTests|CookieProviderCutover|BrowserCookieAccessGate' (after rebase onto a2cf7face)
  • make check — 0 violations
  • CODEXBAR_TEST_SUITE_TIMEOUT=120 CODEXBAR_TEST_GROUP_SIZE=4 make test (pre-rebase): 360 groups; the only failure is UsageStoreCachedTokenHydrationTests timing out at 120 s, which also times out on a clean main locally because it loads the real Codex token cache.
  • ./Scripts/regenerate-plugin-js.sh + tsc --project tsconfig.plugins.json
  • Two adversarial reviewer passes (security/privacy, correctness); all findings fixed (default Off, account match, token scoping, deadline). Final pass: no findings.

@clawsweeper

clawsweeper Bot commented Sep 25, 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.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 Merging this PR could lose, corrupt, stale, or mis-associate session or agent state. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 25, 2026
@clawsweeper

clawsweeper Bot commented Sep 25, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed September 25, 2026, 3:58 PM ET / 19:58 UTC.

ClawSweeper review

What this changes

Adds an opt-in browser-session fallback that reads Muse Code subscription quotas when the CLI login response omits them, with settings, documentation, and tests.

Merge readiness

⛔ Blocked before merge - 7 items remain

This PR addresses a real gap in Muse Code quota display and has useful live CLI evidence. It needs a team-identity repair and provider-privacy sign-off before merge.

Priority: P2
Reviewed head: 6f2a24cd52b7513394f37b5bba1db2e25a7d93ce
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The live idle-window trace is useful, but team selection and its authority proof remain merge blockers.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: Authority-chain proof required: the redacted macOS CLI trace shows the production Muse path filling an idle quota after the fix, but it does not show that a different or reassigned team is rejected before its quota reaches the display. A production-path harness covering that final effect would close the gap; redact private data in posted evidence. No stored-data model changes were identified. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: Authority-chain proof required: the redacted macOS CLI trace shows the production Muse path filling an idle quota after the fix, but it does not show that a different or reassigned team is rejected before its quota reaches the display. A production-path harness covering that final effect would close the gap; redact private data in posted evidence. No stored-data model changes were identified. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Current main behavior: The existing plugin returns plan and identity with an unavailable-quota row when subs_usage is omitted; it has no web fallback.
Introduced team selection: After comparing account emails, the branch returns the first parsed quota among the first two teams without binding that team to the CLI subscription.
Live behavior proof: The submitted redacted trace records the released CLI showing no quota and a branch CLI run showing a 0% idle window and 22.58% weekly usage. It does not exercise a browser account with multiple subscribed teams.
Findings 1 actionable finding [P1] Bind web quota to the CLI subscription's team
Security Needs attention Browser team authority is not bound to CLI subscription: A cookie authorized for multiple teams can provide a quota from the first team while CodexBar presents it as the CLI login's subscription usage.

How this fits together

CodexBar reads Muse Code usage through a bundled provider plugin. The plugin normally uses a CLI device token; this branch also lets it use a browser session to fill missing quota windows before the app or CLI displays them.

flowchart LR
  A[Muse CLI login] --> B[Subscription response]
  B --> C{Quotas present?}
  C -->|Yes| F[Usage display]
  C -->|No| D[Opt-in browser session]
  D --> E[Account and team quota checks]
  E --> F
Loading

Decision needed

Question Recommendation
Should Muse Code use an opt-in browser session for missing quotas once the CLI subscription is bound to the correct team? Approve bounded fallback: Allow the opt-in fallback after team binding and forbidden-account behavior are proven at the final usage display.

Why: This adds a provider credential path governed by the repository's privacy and authentication sign-off policy.

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: Authority-chain proof required: the redacted macOS CLI trace shows the production Muse path filling an idle quota after the fix, but it does not show that a different or reassigned team is rejected before its quota reaches the display. A production-path harness covering that final effect would close the gap; redact private data in posted evidence. No stored-data model changes were identified. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Bind web quota to the CLI subscription's team (P1) - When the same Meta account has two subscribed teams, this loop accepts the first team's quota even if the CLI login belongs to the other team. Email equality does not identify the subscription team, so the displayed weekly usage can be wrong. Establish a team binding or fail closed on ambiguity.
  • Resolve security concern: Browser team authority is not bound to CLI subscription - A cookie authorized for multiple teams can provide a quota from the first team while CodexBar presents it as the CLI login's subscription usage.
  • Resolve merge risk (P1) - A browser account can belong to multiple teams. Selecting the first team with a quota can display another team's usage under the CLI login identity.
  • Resolve merge risk (P1) - The new browser-cookie access affects provider authentication and privacy behavior, which repository policy reserves for sign-off.
  • Complete next step (P2) - Repair ambiguous team selection, provide final-effect proof for wrong-team rejection, and obtain provider privacy sign-off before merge.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

  • [P1] Bind web quota to the CLI subscription's team — Sources/CodexBarCore/Resources/Plugins/muse.ts:97-103
  • [medium] Browser team authority is not bound to CLI subscription — Sources/CodexBarCore/Resources/Plugins/muse.ts:97
Agent review details

Security

Needs attention: The new browser credential path checks account email, but does not establish which subscribed team may supply the displayed quota.

Review metrics

Metric Value Why it matters
Changed surface 14 files; 598 additions, 41 deletions The fallback spans the plugin, native settings, tests, documentation, and generated JavaScript.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #4002
Summary: This PR is the open candidate fix for the linked idle-window Muse Code quota issue.

Members:

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

Merge-risk options

Maintainer options:

  1. Bind and prove the team (recommended)
    Reject ambiguous team results and show that an unrelated team or browser account cannot supply the CLI subscription's displayed quota.
  2. Pause browser fallback
    Defer the new credential path if a reliable CLI-to-team binding cannot be established.

Technical review

Best possible solution:

Bind the web quota to the CLI subscription's team, or fail closed when that binding is ambiguous; retain the opt-in default and obtain approval for browser-session access.

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

Yes for the reported idle-window gap: the linked issue and live CLI trace show missing quota on the released build. The multi-team misassociation follows from the introduced first-match selection and still needs a final-path demonstration.

Is this the best way to solve the issue?

Unclear. An opt-in fallback fits the existing plugin architecture, but team identity must be resolved before the displayed quota can be trusted.

Full review comments:

  • [P1] Bind web quota to the CLI subscription's team — Sources/CodexBarCore/Resources/Plugins/muse.ts:97-103
    When the same Meta account has two subscribed teams, this loop accepts the first team's quota even if the CLI login belongs to the other team. Email equality does not identify the subscription team, so the displayed weekly usage can be wrong. Establish a team binding or fail closed on ambiguity.
    Confidence: 0.91

Overall correctness: patch is incorrect
Overall confidence: 0.87

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a bounded Muse Code quota improvement with a limited affected provider surface.
  • add merge-risk: 🚨 session-state: First-match team selection can associate a different team's quota with the CLI login's displayed usage.
  • add merge-risk: 🚨 security-boundary: The branch consumes an opt-in browser session across the CLI and web account boundary.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Authority-chain proof required: the redacted macOS CLI trace shows the production Muse path filling an idle quota after the fix, but it does not show that a different or reassigned team is rejected before its quota reaches the display. A production-path harness covering that final effect would close the gap; redact private data in posted evidence. No stored-data model changes were identified. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P2: This is a bounded Muse Code quota improvement with a limited affected provider surface.
  • merge-risk: 🚨 session-state: First-match team selection can associate a different team's quota with the CLI login's displayed usage.
  • merge-risk: 🚨 security-boundary: The branch consumes an opt-in browser session across the CLI and web account boundary.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Authority-chain proof required: the redacted macOS CLI trace shows the production Muse path filling an idle quota after the fix, but it does not show that a different or reassigned team is rejected before its quota reaches the display. A production-path harness covering that final effect would close the gap; redact private data in posted evidence. No stored-data model changes were identified. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Security concerns:

  • [medium] Browser team authority is not bound to CLI subscription — Sources/CodexBarCore/Resources/Plugins/muse.ts:97
    A cookie authorized for multiple teams can provide a quota from the first team while CodexBar presents it as the CLI login's subscription usage.
    Confidence: 0.86

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • audreyt: 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.

  • Bind the CLI subscription to a web team or fail closed when team ownership is ambiguous.
  • Add final-effect proof for the nearest unauthorized team and show that stale or reassigned team authority cannot publish its quota.

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.

@steipete

Copy link
Copy Markdown
Owner

Thanks @enieuwy for the implementation and redacted trace. The opt-in default and domain/credential scoping are sound. Closing this version because matching account emails does not identify the subscription: the plugin accepts the first team with a quota and labels it as the CLI plan with exact confidence. A synthetic check changes the displayed weekly usage from 10% to 80% solely by reversing team order; the submitted fixture also accepts an Everyday quota under a Power login. The missing quota still needs a reliable data source, so this is not being closed as unnecessary or already fixed. If you want to take another pass: an explicit, user-selected team (an opt-in setting listing the teams the session can see, no first-match) labeled as a browser-team quota rather than as the CLI plan would be adoptable with the same domain scoping; keep the present/omitted/expired-window fixtures on both engines and add wrong-team and list-order cases.

@steipete

Copy link
Copy Markdown
Owner

Superseded by #4011, which landed the reworked explicit team selection. Closing this earlier version.

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

Labels

merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 Merging this PR could lose, corrupt, stale, or mis-associate session or agent state. P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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.

Muse Code quota disappears while the 5-hour window is idle

2 participants