Skip to content

Classify StepFun Coding vs Token Plan by payload shape, not a hard-coded plan_family - #2492

Merged
steipete merged 2 commits into
steipete:mainfrom
LeoLin990405:fix/stepfun-plan-classification
Jul 29, 2026
Merged

Classify StepFun Coding vs Token Plan by payload shape, not a hard-coded plan_family#2492
steipete merged 2 commits into
steipete:mainfrom
LeoLin990405:fix/stepfun-plan-classification

Conversation

@LeoLin990405

Copy link
Copy Markdown
Contributor

Summary

Closes #2491.

StepFun's isCreditPlan trusted plan_family == 2 ahead of the payload shape. After the 2026-06-18 Step Plan upgrade the grandfathered Coding Plan (rolling 5-hour/weekly windows) and the current Token Plan (monthly Credit pool) both run in the wild, so a windowed payload that ever carried plan_family == 2 — or any future family-id change — would route a rolling-window plan into the credit renderer, dropping the real windows and showing a credit balance the plan doesn't have.

This classifies by the shape the response actually carries and keeps plan_family only as a tie-breaker:

  • a live rolling window (*_reset_time > 0) → Coding Plan (windows);
  • no live window + a Credit pool present → Token Plan (credit);
  • neither → fall back to plan_family == 2.

The credit renderer already only fires when a plan has a Credit pool and no live windows, so the current Token Plan path is unchanged; this just stops the family id from overriding a live window.

Verification

  • swift test --filter StepFun — 39 passed, including two new cases: a live-window payload that also reports plan_family == 2 stays on the rolling-window renderer, and the ambiguous-payload fallback to the family id.
  • Scripts/lint.sh (strict) — 0 violations; SwiftFormat — no changes.
  • Live: ran against a real Token Plan account — still classifies as credit and renders the credit balance as before (no regression).

I don't have a grandfathered Coding Plan account to exercise the window branch live, so that path is covered by a fixture built from the documented shape + the fields observed on QueryStepPlanRateLimit, mirroring the fixture-based approach used for the Alibaba Personal variants in #2487.

@clawsweeper clawsweeper Bot added 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. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. labels Jul 29, 2026
@clawsweeper

clawsweeper Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed July 29, 2026, 12:29 PM ET / 16:29 UTC.

ClawSweeper review

What this changes

This PR makes StepFun choose rolling-window or credit usage rendering from the response payload shape, using plan_family only when the payload is otherwise ambiguous, and adds focused parser coverage.

Merge readiness

Blocked until stronger real behavior proof is added - 3 items remain

Keep this PR open: the focused shape-first classifier appears to address the linked StepFun rendering bug, but the changed grandfathered Coding Plan branch still lacks after-fix runtime proof. Likely related people: steipete is the strongest routing candidate from the follow-up provider work and adjacent plan-parsing history.

Priority: P2
Reviewed head: 4f6b23f39096c824a1e29c93d998e08042e36792

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The implementation and focused coverage are promising, but missing runtime proof for the changed plan type prevents higher merge confidence.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: The reported Token Plan live check supports the unchanged credit path, but the changed Coding Plan rolling-window path still has fixture-only evidence; add redacted live output or an after-fix runtime transcript before merge. 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 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The reported Token Plan live check supports the unchanged credit path, but the changed Coding Plan rolling-window path still has fixture-only evidence; add redacted live output or an after-fix runtime transcript before merge. 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 Shape-first implementation: The proposed StepFun parser changes the plan classification from an authoritative family-id check to payload-shape precedence: live reset windows select rolling-window rendering, with credit information and then the family id used for the remaining cases.
Focused regression coverage: The PR adds coverage for a payload containing both live rolling windows and the credit family id, plus the otherwise-ambiguous family-id fallback.
Exhausted-credit follow-up: The current PR head includes the follow-up commit “fix: recognize exhausted StepFun credit pools,” addressing the case where a real credit plan has no remaining credit.
Findings None None.
Security None None.

How this fits together

CodexBar’s StepFun provider decodes a rate-limit response into a normalized usage snapshot. The resulting snapshot chooses whether the menu bar and widget show five-hour/weekly rolling windows or a monthly credit balance.

flowchart LR
  A[StepFun rate-limit response] --> B[Decode usage fields]
  B --> C{Live reset window?}
  C -->|Yes| D[Rolling-window usage]
  C -->|No| E{Credit pool present?}
  E -->|Yes| F[Credit-balance usage]
  E -->|No| G[Family-id fallback]
  D --> H[Menu and widget rows]
  F --> H
  G --> H
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The reported Token Plan live check supports the unchanged credit path, but the changed Coding Plan rolling-window path still has fixture-only evidence; add redacted live output or an after-fix runtime transcript before merge. 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.
  • Resolve merge risk (P1) - A grandfathered Coding Plan may have provider-side payload details not represented by the fixture; without redacted after-fix runtime evidence, maintainers cannot confirm that live reset windows reach the expected rendered rows.
  • Complete next step (P2) - A contributor-supplied real-behavior proof for the changed Coding Plan path is needed before maintainers can make a merge decision.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Focused surface 2 files affected; 117 added, 24 removed The branch is limited to the StepFun usage parser and focused parsing tests.
Classification coverage 2 new decision cases The added tests cover conflicting live-window/family data and the otherwise-ambiguous family fallback.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #2491
Summary: This PR is the implementation candidate for the open StepFun plan-classification report.

Members:

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

Merge-risk options

Maintainer options:

  1. Add Coding Plan runtime proof (recommended)
    Provide a redacted live Coding Plan response or after-fix transcript showing nonzero reset times render as rolling five-hour and weekly windows.
  2. Accept fixture-only coverage
    Merge with the existing fixture coverage only if maintainers explicitly accept the remaining uncertainty for grandfathered Coding Plan accounts.

Technical review

Best possible solution:

Retain the payload-shape classifier and add redacted after-fix Coding Plan output that demonstrates nonzero reset times render as five-hour and weekly usage before merging.

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

Unclear: the fixture and focused tests establish the intended conflicting-payload path, and the PR reports a live Token Plan check, but no after-fix runtime evidence exists for the changed grandfathered Coding Plan window path.

Is this the best way to solve the issue?

Yes, conditionally: preferring observed payload shape over a hard-coded family id is the narrower and more resilient repair, provided the exhausted-credit-pool handling remains structurally detected and live behavior is confirmed.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against c52b0efa13b0.

Labels

Label justifications:

  • P2: This is a bounded provider-usage rendering correction that can misrepresent affected StepFun account usage without disrupting the core application runtime.
  • merge-risk: 🚨 compatibility: Changing the classifier can alter which usage renderer existing StepFun accounts receive after upgrading.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The reported Token Plan live check supports the unchanged credit path, but the changed Coding Plan rolling-window path still has fixture-only evidence; add redacted live output or an after-fix runtime transcript before merge. 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

What I checked:

Likely related people:

  • steipete: Authored the current-head follow-up for exhausted StepFun credit pools and recently merged adjacent provider-plan parsing work, making them the best-supported owner for the current renderer boundary. (role: recent area contributor; confidence: medium; commits: 4f6b23f39096, d04c74a71b1a; files: Sources/CodexBarCore/Providers/StepFun/StepFunUsageFetcher.swift, Tests/CodexBarTests/StepFunUsageFetcherTests.swift)

Rank-up moves

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

  • Add redacted after-fix Coding Plan evidence showing live reset windows render as five-hour and weekly usage.
  • Update the PR body with that proof; if a fresh review does not start automatically, ask a maintainer to comment @clawsweeper re-review.

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 (1 earlier review cycle)
  • reviewed 2026-07-29T12:57:28.158Z sha 1401d62 :: needs real behavior proof before merge. :: none

LeoLin and others added 2 commits July 29, 2026 09:22
…ded plan_family

StepFun runs two Step Plan billing models side by side after the 2026-06-18
upgrade (docs/zh/step-plan/upgrade-notice): the grandfathered Coding Plan meters
rolling 5-hour/weekly windows, while the current Token Plan meters a monthly
Credit pool via plan_credit_rate_limit (its rate windows come back as 0 with
reset_time "0").

isCreditPlan trusted plan_family == 2 first, so a windowed plan that ever
reported plan_family=2 (or any future family-id change) would route to the
credit renderer — dropping the real 5h/weekly windows and showing a bogus credit
balance. Classify by the shape the payload actually carries (a live window reset
time means Coding Plan; no window plus a Credit pool means Token Plan) and use
plan_family only as a tie-breaker for an otherwise-ambiguous payload.

Adds tests for the window-wins-over-family-id case and the ambiguous fallback.
Verified live against a Token Plan account (still renders the credit balance).
@steipete
steipete force-pushed the fix/stepfun-plan-classification branch from 1401d62 to 4f6b23f Compare July 29, 2026 16:25
@steipete
steipete merged commit 5213ebf into steipete:main Jul 29, 2026
9 checks passed
@steipete

Copy link
Copy Markdown
Owner

Merged after full verification. StepFun plans are now classified by payload shape — live reset windows take precedence over plan_family, with the family-ID fallback retained.

Fixed during review: hasCreditPool required a positive credit balance or non-empty buckets, so an exhausted zero-credit pool was misclassified — exactly the state a user hits when they've run out, and worst if the family ID is missing or changed. It now detects credit-field presence (including an explicit zero and the top-up field), with regressions for the exhausted-pool and zero-with-top-up cases. Thanks @LeoLin990405!

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

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. 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.

StepFun: classify Coding Plan vs Token Plan by payload shape, not a hard-coded plan_family == 2

2 participants