Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1799,6 +1799,15 @@ generator.
> what actually ran. Warned by default; `--fail-on-substitution` refuses on the
> estimate, before any spend.

**When the estimate says `Resources ready: false`.** The CLI refuses to submit
by default. `--allow-not-ready` submits anyway, which is what the site's own
generator does (it shows a *Potentially slow generation* notice and lets you
generate). Image edits on the OpenAI ecosystem (`--ecosystem OpenAI --image …`)
were measured reporting `ready: false` on every estimate while the same job ran
from the site, so they need the flag. A `ready: false` job may start late or
never produce an output, and like any submit it is charged when the server
accepts it.

**Which Buzz pays.** `--buzz-type blue|yellow|green` picks the account, the
same choice as the **Pay with** menu in the site's generator. Without it the
server decides: blue first, then the site's own Buzz. On civitai.red the site
Expand Down
54 changes: 47 additions & 7 deletions internal/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ type generateOpts struct {
// server preserves a substitution deliberately so that a script pinned to a
// retired version keeps working. See the flag registration for the argument.
failOnSubstitution bool
// allowNotReady submits even when the estimate reports ready:false. Opt-in:
// the DEFAULT stays the refusal. See the flag registration for the argument.
allowNotReady bool

// noWait prints the workflow id and exits instead of waiting.
noWait bool
Expand Down Expand Up @@ -395,8 +398,14 @@ checkpoint, name the --ecosystem it belongs to as well.
server's ` + "`ready`" + ` flag, which reports only that the resources this job needs are
currently available — nothing about moderation, and nothing about whether the
job will actually produce an image. A run that reports resources ready can still
be charged and return nothing. Treat ` + "`ready: false`" + ` as "do not submit"; do not
read ` + "`ready: true`" + ` as a green light.
be charged and return nothing; do not read ` + "`ready: true`" + ` as a green light. By
default this CLI refuses a ` + "`ready: false`" + ` job. --allow-not-ready submits it
anyway, as the site's own generator does (it shows a "Potentially slow
generation" notice and lets you generate); the job may start late or never
produce an output, and like any submit it is charged when the server accepts
it. Image edits
on the OpenAI ecosystem (--image) were measured reporting ` + "`ready: false`" + ` on
every estimate while the same job ran from the site.

WAITING AND DOWNLOADING: by default the command waits for the job to finish and
writes every deliverable output into --out-dir as <workflow-id>-<n>.<ext>.
Expand Down Expand Up @@ -698,6 +707,23 @@ path that resolves model ids before anything is submitted.`,
// command in this bool flag's usage rendered it in --help as a flag that
// takes a value called "civitai workflows get <id>" (measured, then fixed).
// Use single quotes. Pinned by TestGenerateFlagUsageHasNoBackquotes.
// 🔴 OPT-IN, AND THE REFUSAL STAYS THE DEFAULT. `ready: false` is the
// server's capacity signal (some step's queuePosition.support is not
// 'available'), and the refusal it triggers is THIS CLI's own: nothing on
// the server's submit path reads it (AGENTS.md item 28(a)). The site's own
// generator does not gate on it either — civitai/civitai
// src/components/generation_v2/ResourceAlerts.tsx renders a "Potentially
// slow generation" notice for ready:false with no download preparation and
// leaves Generate enabled. Measured 2026-12-04: every gpt-image-2.5 edit
// (OpenAI + --image) estimate reports ready:false while the same job from the
// site's generator runs, so without this flag that whole job class is
// unreachable from the CLI. The usage string must not promise output — a
// ready:false job may also be one the server cannot run, and it is charged
// either way.
cmd.Flags().BoolVar(&o.allowNotReady, "allow-not-ready", false,
"submit even when the estimate reports ready: false (the default refuses). The site's own generator does the same: "+
"it shows a 'Potentially slow generation' notice and lets you generate. ready: false means the server cannot "+
"start the job right away, and it can also mean the job will never run; like any submit, it is charged when the server accepts it")
cmd.Flags().BoolVar(&o.noWait, "no-wait", false,
"submit, print the workflow id and exit without waiting; collect the results later with 'civitai workflows get <id>'")
// 🔴 The wording here is load-bearing. --timeout bounds the CLI's WAIT. The
Expand Down Expand Up @@ -1346,12 +1372,17 @@ func runGenerate(cmd *cobra.Command, deps generateDeps, o generateOpts) error {
return err
}

if !quote.Ready {
if !quote.Ready && !o.allowNotReady {
// `ready:false` means some job in the workflow has no available support —
// the resources are not currently available. Submitting anyway spends on
// a job the server has already said it cannot serve.
// a job the server has already said it cannot serve right now.
return civitai.Tag(civitai.ErrBadRequest, fmt.Errorf(
"the server reports the resources for this job are not currently available (ready: false) — they may be unavailable or unsupported by this workflow; inspect the estimate with --dry-run --json"))
"the server reports the resources for this job are not currently available (ready: false) — they may be unavailable or unsupported by this workflow; inspect the estimate with --dry-run --json, or pass --allow-not-ready to submit anyway"))
}
if !quote.Ready {
// --allow-not-ready: proceed, but say so BEFORE the confirmation, where a
// human can still decline.
fmt.Fprintln(errw, ui.For(errw).Warn(allowNotReadyWarning))
}

cost := quote.Cost.Total
Expand Down Expand Up @@ -2021,6 +2052,11 @@ func confirmGenerate(cmd *cobra.Command, o generateOpts, built *resolvedGraph, c
// reports what the estimate did rather than what the user typed.
const promptNotChecked = "<not checked by --dry-run>"

// allowNotReadyWarning is the ONE line both the --dry-run quote and the submit
// path print for a ready:false estimate under --allow-not-ready. It states what
// the server said and what this CLI will do, and promises no output (item 28).
const allowNotReadyWarning = "The server reports the resources for this job are NOT currently available (ready: false). --allow-not-ready is set, so this CLI submits it anyway: it may start late or never produce an output, and like any submit it is charged when the server accepts it."

// printGenerateQuote renders the --dry-run breakdown. Factor and fixed keys are
// printed VERBATIM — they are server-owned, and inventing friendlier labels is
// how a vendored mapping starts.
Expand Down Expand Up @@ -2162,8 +2198,12 @@ func printGenerateQuote(out, errw io.Writer, built *resolvedGraph, o generateOpt
// #279's failing checkpoints came back as HTTP 400s rather than as
// ready:false. Caveating `true` as unobservable while promoting `false`
// on the same unread evidence is the same mistake twice.
fmt.Fprintln(errw, ui.For(errw).Warn(
"The server reports the resources for this job are NOT currently available (ready: false) — this CLI refuses to submit in that state."))
if o.allowNotReady {
fmt.Fprintln(errw, ui.For(errw).Warn(allowNotReadyWarning))
} else {
fmt.Fprintln(errw, ui.For(errw).Warn(
"The server reports the resources for this job are NOT currently available (ready: false) — this CLI refuses to submit in that state."))
}
}
// The caveat belongs on stderr next to the number, every time. A user who
// reads only the total will otherwise treat it as a quote.
Expand Down
90 changes: 90 additions & 0 deletions internal/cmd/generate_allow_not_ready_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package cmd

import (
"strings"
"testing"
)

// --allow-not-ready: a ready:false estimate is SUBMITTED (once) instead of
// refused, and the user is told so on stderr before the submit. The default
// refusal is TestGenerate_NotReadyRefuses; this is the opt-in direction.
//
// Why the flag exists: every gpt-image-2.5 edit estimate (OpenAI + --image)
// was measured reporting ready:false while the same job runs from the site's
// generator, which never gates on the flag (ResourceAlerts.tsx shows a
// "Potentially slow generation" notice and leaves Generate enabled).
func TestGenerate_AllowNotReadySubmits(t *testing.T) {
var s genSeams
s.whatIf = notReadyQuoteSeam()
o := baseOpts()
o.assumeYes = true
o.allowNotReady = true
c, _, errb := genCmd("")
if err := runGenerate(c, s.deps(t), o); err != nil {
t.Fatalf("ready:false with --allow-not-ready: want a submit, got %v", err)
}
if s.submitCalls != 1 {
t.Errorf("ready:false with --allow-not-ready: submit called %d times, want 1", s.submitCalls)
}
if !strings.Contains(errb.String(), allowNotReadyWarning) {
t.Errorf("the submit must say it is proceeding past ready:false:\n%s", errb.String())
}
}

// The flag changes nothing for a ready:true estimate: no warning, one submit.
// Guards the warning against firing on every run once the flag is in a script.
func TestGenerate_AllowNotReadySilentWhenReady(t *testing.T) {
var s genSeams
o := baseOpts()
o.assumeYes = true
o.allowNotReady = true
c, _, errb := genCmd("")
if err := runGenerate(c, s.deps(t), o); err != nil {
t.Fatalf("ready:true with --allow-not-ready: %v", err)
}
if s.submitCalls != 1 {
t.Errorf("submit called %d times, want 1", s.submitCalls)
}
if strings.Contains(errb.String(), "ready: false") {
t.Errorf("a ready:true estimate must not print the not-ready warning:\n%s", errb.String())
}
}

// --dry-run must not say "this CLI refuses to submit" when the flag means a
// real run would submit. It still reports the server's false and spends nothing.
func TestDryRun_AllowNotReadyStatesItWouldSubmit(t *testing.T) {
withStdinTTY(t, false)
var s genSeams
s.whatIf = notReadyQuoteSeam()
o := baseOpts()
o.dryRun = true
o.allowNotReady = true
c, out, errb := genCmd("")
if err := runGenerate(c, s.deps(t), o); err != nil {
t.Fatalf("--dry-run --allow-not-ready: %v", err)
}
if s.submitCalls != 0 {
t.Errorf("--dry-run submitted %d times, want 0", s.submitCalls)
}
if !strings.Contains(collapseWS(out.String()), "Resources ready: false") {
t.Errorf("the readiness line must still report the server's false:\n%s", out.String())
}
if !strings.Contains(errb.String(), allowNotReadyWarning) {
t.Errorf("--dry-run with the flag must print the proceed warning:\n%s", errb.String())
}
if strings.Contains(errb.String(), "refuses to submit in that state") {
t.Errorf("--dry-run with the flag must not claim a refusal a real run would not make:\n%s", errb.String())
}
}

// The flag is registered on the real command, off by default, so the refusal
// stays the default for every existing caller.
func TestGenerate_AllowNotReadyFlagRegisteredOffByDefault(t *testing.T) {
f := newGenerateCmd().Flags().Lookup("allow-not-ready")
if f == nil {
t.Fatal("generate has no --allow-not-ready flag")
}
if f.DefValue != "false" {
t.Errorf("--allow-not-ready default = %q, want false (the refusal is the default)", f.DefValue)
}
}
15 changes: 15 additions & 0 deletions internal/cmd/generate_golden_copy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,21 @@ func TestGoldenSpendCopy(t *testing.T) {
assertGolden(t, "generate_flag_usage_timeout", f.Usage)
})

// --- --allow-not-ready: the flag usage and the warning ------------------
// Both tell the user a ready:false job is charged when the server accepts
// it. The warning is the line printed beside the confirmation (and on the
// --dry-run quote), so it is the copy read at the moment of spending.
t.Run("generate_flag_usage_allow_not_ready", func(t *testing.T) {
f := newGenerateCmd().Flags().Lookup("allow-not-ready")
if f == nil {
t.Fatal("CONTROL failure: --allow-not-ready is gone")
}
assertGolden(t, "generate_flag_usage_allow_not_ready", f.Usage)
})
t.Run("generate_allow_not_ready_warning", func(t *testing.T) {
assertGolden(t, "generate_allow_not_ready_warning", allowNotReadyWarning)
})

// 🔴 THE --input UNKNOWN-KEY WARNING, ADDED BY #343 — AND IT IS THE THIRD
// TIME THIS FILE'S HEADER HAS BEEN PROVED RIGHT. This surface was not pinned,
// and what it said was: "the server SILENTLY IGNORES keys it does not declare:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The server reports the resources for this job are NOT currently available (ready: false). --allow-not-ready is set, so this CLI submits it anyway: it may start late or never produce an output, and like any submit it is charged when the server accepts it.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
submit even when the estimate reports ready: false (the default refuses). The site's own generator does the same: it shows a 'Potentially slow generation' notice and lets you generate. ready: false means the server cannot start the job right away, and it can also mean the job will never run; like any submit, it is charged when the server accepts it
Loading
Loading