Live Replicate client: poll/API contract, pinned models, and hero JPEG #5
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Make the live Replicate client match production HTTP, pin model/version in config, poll until terminal status, and write hero JPEG bytes so frontmatter
imagedoes not 404. Replace--skip-imagedefault-true with an explicit--imageopt-in. Add cassette tests for poll/API shape.Gap:
gaps/GAP_1788152435.md§2 (hero, model pin), §5 (redirects, budget-before-POST, poll), §6.2 (skip_image).Voice/image contract remains
CL8Y-webblog_gen/SKILL.mdandblog_gen/generate_image.py(onepredictions.createper command, poll by id, never retry create).Current codebase
src/replicate.rs:FixturePredictoris well tested (create-once, budget, drop-after-create).HttpPredictorPOSTshttps://api.replicate.com/v1/predictionswith JSON{ "model", "input": { prompt, step } }— unverified vs current Replicate API (classic wantedversion; models API isPOST /v1/models/{owner}/{name}/predictions).redirect(Policy::none())(indexer client correctly disables redirects).create_countincrement before POST. Network failure burns budget with no id.pollreturns on first HTTP 200 even ifstatusisstarting/processing. Loop is 8 × 400ms — too short for image/text jobs.step_textsendsmodel: "fixture-or-replicate"for every text step.src/pipeline.rsimage step:create_oncefor"image"then does not download or write a JPEG. Frontmatter still setsimage: /images/blog/<slug>-hero.jpg.src/main.rs:--skip-imagedefault_value_t = true. Enabling a hero is--skip-image=false. Fixture herofixtures/assets/hero.jpgis a 158-byte 1×1 JPEG.DEFAULT_WEEKLY_CREATE_BUDGETis 6 (plan, outline, draft, editor bundle, optional image).Why this is needed
--livecannot be trusted in production. Visitors will 404 heroes. Operators cannot recover creates. Model ids must be pinned so spend and output are reproducible.Constraints / guardrails
predictions.createper step. Never retry create. Recover withcl8y-research fetch PREDICTION_ID/poll.succeeded/failed/canceledwith backoff suitable for GPT-image and long text (minutes, not 3.2s).api.replicate.comonly; no redirects; token never logged.FixturePredictor.--imageis off. Do not loop "until it looks good."--imageopt-in (default off). When off, still write a valid JPEG placeholder so the frontmatter path exists (copyfixtures/assets/hero.jpgor a committed placeholder). When on, download prediction output and write<out>/hero.jpg/ API blob. Cap download size; verify JPEG magic bytes.Relevant files
src/replicate.rssrc/pipeline.rsstep_text, image create without writesrc/main.rs--live,--skip-imagesrc/config.rsweekly_create_budget, tokensrc/invariants.rsDEFAULT_WEEKLY_CREATE_BUDGETfixtures/happy-week/replicate.jsonfixtures/assets/hero.jpgCL8Y-web/blog_gen/generate_image.pyRecommended direction
REPLICATE_TEXT_MODEL,REPLICATE_IMAGE_MODEL(and optional version). Fail--liveif unset.starting→succeeded+ image bytes.poll: loop whilestarting/processing; honorRetry-Afterif present; cap total wait.FF D8.--imageflag (default false). Deprecate--skip-image.Acceptance criteria
--livewithout pinned model env fails closed (no"fixture-or-replicate"on the wire).starting, poll 2× processing then succeeded → one create, output used.fetchrecovers; no second create.--image: JPEG written next topost.mdx; frontmatter path matches file.--image: placeholder JPEG still written so the path does not 404.REPLICATE_API_TOKEN.Test plan — functional paths
image/jpeg.fixture-or-replicate.--imageclap — default off; on writes generated file.Test plan — attack, hack, and abuse
169.254.169.254.REPLICATE_API_TOKEN/<script>fails emit.report.mdhas prediction ids only, not bearer token.Verification criteria
--fetchagainst a real prediction id.runs/latestfor a JPEG when--imageis used, and a placeholder JPEG when it is not.marked as related to #10
marked as related to #6
mentioned in issue #12
marked as related to #12