Skip to content

Port upstream 0.64.1: Neuralwatt retry, validation and endpoint parity - #624

Open
Finesssee wants to merge 1 commit into
port/upstream-0.64.1from
port/micro-0.64.1-neuralwatt-parity
Open

Finesssee wants to merge 1 commit into
port/upstream-0.64.1from
port/micro-0.64.1-neuralwatt-parity

Conversation

@Finesssee

Copy link
Copy Markdown
Collaborator

Summary

Brings the native Neuralwatt provider (rust/src/providers/neuralwatt/) in line with the behavior upstream keeps after moving Neuralwatt to the bundled neuralwatt.js plugin in v0.64.1:

  • One retry of a transient quota failure: HTTP 408/429/500/502/503/504, and timeout, connection lost/reset, connection refused and DNS errors. The delay is Retry-After (non-negative number, capped at 10 s) or 1 s. There is no second retry; the final failure reads Neuralwatt API error: HTTP <status> (previously HTTP 503 Service Unavailable). 401/403 stay AuthRequired and are never retried, TLS handshake failures are never retried, and cancelling the fetch (refresh timeout) drops the retry sleep with the future.
  • SubscriptionMetadata.renews_at is set from subscription.current_period_end unless subscription.auto_renew == false.
  • Parse failure when balance is missing, or when none of credits_remaining_usd >= 0, credits_used_usd >= 0, total_credits_usd > 0 is usable. Present-but-invalid timestamps and wrong-typed fields (including usage.*.requests/tokens non-integers) are parse failures, as in upstream's schema checks.
  • The login-method fallback title-cases accounting_method (energy becomes Energy) whenever there is no plan, including when subscription is null (previously it only applied inside a non-null subscription and was not capitalized). Plan and key-allowance labels use the same upstream title casing.
  • NEURALWATT_API_URL must be HTTPS or a bare host (promoted to HTTPS), otherwise the fetch fails with Neuralwatt endpoint override NEURALWATT_API_URL must use HTTPS or a bare host. A configured ?query is kept after /v1/quota. Validation reuses the shared providers::validated_https_url.
  • The subscription reset date is now kept when current_period_start is absent (upstream sets resetsAt from the end alone); the window length is still only set when both ends are present.

Retry logic is provider-local (no shared retry layer). The retry delay is an argument of the private fetch_quota, so tests run without waiting.

Upstream reference

  • v0.64.1 release: "Neuralwatt: use the bundled quota plugin while preserving subscription usage, prepaid balances, key allowances, selective retries and cancellation" (refactor(providers): move configured proxy usage into plugins steipete/CodexBar#3811, 18ee35247).
  • Tag-pinned sources (v0.64.1): Sources/CodexBarCore/Resources/Plugins/neuralwatt.js, Sources/CodexBarCore/ProviderHTTPClient.swift (ProviderHTTPRetryPolicy.transientIdempotent), Sources/CodexBarCore/Providers/NeuralWatt/NeuralWattSettingsReader.swift (validateEndpointOverrides), NeuralWattProviderDescriptor.swift, TestsPlugin/NeuralWattPluginTests.swift (fixtures and malformed-body list), docs/neuralwatt.md.

Ported / Deferred

Ported: everything listed in Summary.

Not ported (no Windows counterpart or already matching): the plugin-engine migration itself (Swift/QuickJS), the cost shape (upstream reports the balance as used/limit: 0; Windows keeps CostSnapshot::with_balance with used/limit), and percent-decoding of the base path before the /v1 check. Connection-closed detection uses the hyper message connection closed before message completed because hyper is not a direct dependency. No deferrals of wire shapes.

Validation

Run in this worktree with a process-local CARGO_TARGET_DIR outside every worktree (equivalent to scripts/worktree-env.ps1; the script cannot run under this agent's worktree guard because it calls git):

  • cargo fmt --all: clean.
  • cargo test -p codexbar neuralwatt: 18 passed, 0 failed (upstream quota fixtures 0-9, malformed bodies, auto_renew true/false/absent, endpoint override, retry exactly 2 requests for 503 and 429-then-200, no retry for 400/401/403/404, timeout and lost-connection retry on a raw-socket stub, TLS handshake not retried, retry sleep dropped when the fetch future is cancelled).
  • cargo clippy -p codexbar --all-targets -- -D warnings: no findings in neuralwatt. It reports 3 pre-existing errors in files this PR does not touch (alibabatokenplan/cli.rs:163, kiro/usage_limits.rs:315, openai/subscription.rs:206; new lints in the installed rustc 1.96). They are also present on the base branch.
  • Not run: full cargo test -p codexbar (no shared code touched), Tauri crate tests (not touched).

Affected areas

  • Rust backend / provider (Neuralwatt only)
  • Tauri shell / frontend / tray / settings / float bar
  • Docs

UI proof

Not applicable. No UI surface changed; the renewal date renders through the existing subscription-metadata path.

@coderabbitai

coderabbitai Bot commented Sep 28, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: bb35e5bf-11a3-4eb0-a7e7-81f3428939db

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Validation on the CI-pinned toolchain (Rust 1.98.0, scripts/circleci-pinned-rust.txt), run at head c24373b0:

  • cargo +1.98.0 fmt --all --check: clean
  • cargo +1.98.0 clippy --workspace --all-targets -- -D warnings: clean, including the Tauri crate
  • cargo +1.98.0 test -p codexbar neuralwatt: 18 passed, 0 failed

The three clippy errors mentioned in the PR body are in files this PR doesn't touch. They only appear on the machine's older default toolchain (1.96.1); main and this branch are both clean on 1.98.0.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant