Skip to content

bug: a repository model is not treated as an own model when quota is checked #732

Closed

Description

@HugoXK

Written-by: HugoXK

Expected behaviour

A model selected for a repository is the model the job runs on, so it must count as an own model everywhere: the first-run checklist, the dashboard's quota next action, and the job enqueue quota check. A user with such a model can start a job after the platform quota is exhausted, and the model step is not marked done just because a provider row exists.

When the platform quota is the fallback, the model step must also tell the truth about that quota:

  • Show the current remaining platform balance.
  • Below PLATFORM_QUOTA_COMFORT_CNY (50 CNY), warn that the balance may not cover the first run and recommend configuring an own model now — or selecting one for the repository when a provider already exists.
  • At 50 CNY or more (or when the account is unlimited), show only the remaining balance and keep Settings → Model as the place to configure a model later, with no warning.
  • The threshold changes the advice only; it never changes quota accounting or the gateway.

Actual behaviour

  • src/app.ts marks the model step done when any provider has any model, even if no repository selected one.
  • src/gateway/gateway.ts only uses a repository model when it is in repo_model_selection; otherwise the call is platform-funded.
  • src/jobs/service.ts decides platformFunded from the legacy users.own_llm_* fields only, so a repository-selected model still gets QUOTA_EXHAUSTED when the platform quota is empty.
  • src/views/pages.ts shows the quota "Add your own model" action unconditionally when the quota is exhausted, even when a usable own model exists.
  • The platform-satisfied model step says only "Using platform quota (default)" and never says how much is left or whether that is enough for a first run.

Reproduction

  1. Create a user with quota_cny = 0 (or spend the default quota).
  2. Add a provider and a model in Settings, then select that model for a repository.
  3. Start a job.

Expected: the job is dispatched through the repository model. Actual: enqueue returns QUOTA_EXHAUSTED before the gateway is called. The dashboard also offers "Add your own model" and may mark the model step done before the repository selection exists. A new account with the default 1 CNY quota is treated as if the platform balance were a comfortable default instead of a warning.

Scope

  • src/app.ts: derive modelConfigured from a usable own model (legacy own model or a repository selection), keep providerConfigured separate, and pass the remaining platform quota into the checklist.
  • src/views/checklist.ts: a provider without a repository selection is not a completed model step; link it to the repository picker. A selected model satisfies the step. When the platform quota is the fallback, show the balance and the low/high advice described above.
  • src/views/pages.ts and public/app.css: show the quota warning in the checklist row and suppress the exhausted-quota next action when a usable own model exists.
  • src/jobs/service.ts: treat a repository selection as non-platform-funded in both enqueue and dispatch.
  • Tests in test/setupChecklist.test.ts, test/nextAction.test.ts, test/jobs.test.ts; docs in docs/architecture.md and docs/quota.md; one changelog fragment.

Out of scope: changing the gateway fallback, quota accounting, or auto-binding a provider to every repository.

Verification

  • A repository with a selected model and an exhausted quota enqueues.
  • A repository without a selection and an exhausted quota is still refused as today.
  • The first-run model step is not done when only a provider exists, and links to the repository picker.
  • The quota next action is absent when a usable own model exists.
  • A 1 CNY platform balance shows a warning and an "add your own model now" action; a 50 CNY balance (or unlimited) shows only the balance and the later Settings → Model path.
  • npm run check passes.

Activity

  1. HugoXK commented on Nov 15, 2026

    @HugoXK
    OwnerAuthor

    Written-by: HugoXK

    Claimed on branch fix/732-repo-model-readiness; PR #733 is open. The fix makes a repository-selected model the own-model signal in the checklist, the quota next action and the enqueue/dispatch quota checks.

  2. HugoXK-bot commented on Nov 15, 2026

    @HugoXK-bot
    Collaborator

    Issue-review: PASS at issue #732 body ff778233d7e7
    Written-by: HugoXK-bot

    Hashes re-read this turn: raw ff778233d7e7, trimmed 11772aef40ba. issue-gate: no-pass #732, exit 2 before this verdict.

    The card pinpoints the four places where a repository selection was not treated as an own model (checklist, dashboard quota action, enqueue, dispatch) and fixes the scope to those, with the gateway fallback and quota accounting explicitly out of scope. The PR #733 (e48822384ea4, my PASS 5908787902) implements that scope: platformFundedFor() shared by enqueue and dispatch, providerConfigured separated from modelConfigured in the checklist, and the quota card suppressed only when an own model exists; its tests cover provider-without-selection, selection, and the exhausted-quota enqueue path.

    Ran:

    • node scripts/issue-hash.mjs --repo HugoXK/fledge --issue 732 — raw ff778233d7e7 / trimmed 11772aef40ba
    • node scripts/issue-gate.mjs --repo HugoXK/fledge --issue 732 — no-pass, exit 2
    • npx tsx --test test/jobs.test.ts test/nextAction.test.ts test/nextScheduledRun.test.ts test/setupChecklist.test.ts at e48822384ea4 — pass 135/135

    Conclusion: PASS — the reproduction, expected behaviour and scope name one defect and the tests the card asks for exist in the fix.

  3. added
    review:approvedIssue reviewed and approved by the Fledge Platform Reviewer
    on Nov 15, 2026
  4. HugoXK commented on Nov 15, 2026

    @HugoXK
    OwnerAuthor

    Written-by: HugoXK

    Correction: the fix stays in PR #733, which is open again. PR #678 is being reused for a different approved issue, not #732.

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

Metadata

Metadata

Assignees

Labels

agent-pragent-readyReady for an agent to implementagent-workingarea:gatewayarea:jobsJob lifecycle, queue, callbacksarea:uiViews, CSS, accessibility, i18nbugSomething isn't workingreview:approvedIssue reviewed and approved by the Fledge Platform Reviewer

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions