Skip to content

feat(ai): spike official image API behind a default-off release gate - #239

Closed
alirezasafaei-dev wants to merge 17 commits into
mainfrom
feat/official-image-provider-default-off
Closed

alirezasafaei-dev wants to merge 17 commits into
mainfrom
feat/official-image-provider-default-off

Conversation

@alirezasafaei-dev

@alirezasafaei-dev alirezasafaei-dev commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

Scope — default-off image generation candidate (not a production release)

Phase A: official provider. A fixed-model Cloudflare Workers AI @cf/black-forest-labs/flux-1-schnell server adapter, explicit separate Free-account attestation, bounded bytes/pixels and metadata-stripping JPEG re-encoding. It never retries or scrapes FlatAI.

Phase B: fail-closed backend. POST /api/ai/image demands trusted same-origin POST, explicit consent, valid input and an atomically reserved image quota. All image: HMAC keys use the existing PostgreSQL table but never overwrite chat counters. Hard limits: 1/visitor/day, 1/visitor/minute, 5/account/day and 1/account/minute. Image account/token must be distinct from existing chat credentials. All image flags default OFF.

Phase C: opt-in Persian UI. Adds RTL /ai/image, responsive two-panel description/preview/download, full keyboard-labelled form, consent to transmission to Cloudflare, in-memory blob JPEG URL with cleanup, 45-second timeout, stop/late-response safeguards, quota/error UX and no automatic retry/history. The /ai hub only links when the backend gates are verified and enabled. The image page remains noindex/nofollow even on an enabled test deployment. No production flags or accounts modified.

Evidence / checks

  • 6 JSdom UI tests: PASS on current source (disabled, consent, preview and download link, API errors, MIME rejection, cancellation).
  • 40 existing focused provider/quota/API mock tests: PASS before Phase C, with hosted ci-core retesting branch.
  • 2 real PostgreSQL concurrency/rollback tests: PASS locally and in dedicated GitHub Actions on an ephemeral DB.
  • Independent synthetic Chrome E2E workflow added for JPEG pixel decode, real browser download, 429 messages and serious/critical Axe checks. Uses dummy account IDs and entirely browser-intercepted API responses; never tests provider validity.
  • Prettier, targeted TypeScript (including test matcher setup), pnpm security:secrets, and git diff --check: PASS locally.
  • First Phase C CI run identified 2 new lint errors, corrected; first synthetic browser E2E run identified an ambiguous Playwright field selector, corrected. Current exact head: 921d2e494d2ef0539f12eee66c3125f517f12632. Its six hosted workflows must be checked to completion; no assumption that the previous SHA's green checks carry over.

Unresolved / NO-GO for merge or deployment

  • Independent owner verification that the dedicated Cloudflare account really is Workers Free with no paid upgrade/charging exposure and least-privilege token.
  • Supervised single real output, measured Neurons/latency and Iran connectivity, separate IP/concurrency and operational budget review.
  • Final hosted CI success for the same SHA, independent security/code and physical-mobile/manual screen reader review.
  • Explicit owner authorization for merge/deploy under AGENTS.md. No deployment, real inference, Cloudflare token access, DNS or production changes in this PR.

Tracked at #238. Legacy FlatAI draft #229 remains untouched, blocked and not bypassed.

Signed-off-by: alirezasafaeigfx <alirezasafaei.gfx@gmail.com>
Signed-off-by: alirezasafaeigfx <alirezasafaei.gfx@gmail.com>

Copy link
Copy Markdown
Owner Author

CI corrective follow-up — 2026-10-11

First CI run 38161442675 reported seven curly lint errors in the new provider adapter (not a runtime/provider failure). Reproduced from the exact GitHub job log and fixed all seven in DCO-signed commit d6d83b945d1ac6fe3314f2a58303e29c80da45b1. This is the current branch head.

Fresh targeted evidence after fix: 15/15 mock-only tests PASS, targeted TypeScript check exit 0, Prettier and diff check PASS. At the new exact-head CI run 38161762454, quality, security-audit, contracts, licensing-docs, smoke-asdev and build jobs have completed SUCCESS; end-to-end browser shards are still executing at this checkpoint. CodeQL 38161762158 and AI-chat workspace 38161762096 completed SUCCESS. Lighthouse 38161762097 still executing. Do not infer an overall workflow PASS before all jobs complete.

No image provider inference was sent; PR stays Draft / NO-GO, no merge or deploy.

Signed-off-by: alirezasafaeigfx <alirezasafaei.gfx@gmail.com>
Signed-off-by: alirezasafaeigfx <alirezasafaei.gfx@gmail.com>
Signed-off-by: alirezasafaeigfx <alirezasafaei.gfx@gmail.com>
Signed-off-by: alirezasafaeigfx <alirezasafaei.gfx@gmail.com>
Signed-off-by: alirezasafaeigfx <alirezasafaei.gfx@gmail.com>
Signed-off-by: alirezasafaeigfx <alirezasafaei.gfx@gmail.com>
Signed-off-by: alirezasafaeigfx <alirezasafaei.gfx@gmail.com>
Signed-off-by: alirezasafaeigfx <alirezasafaei.gfx@gmail.com>
Signed-off-by: alirezasafaeigfx <alirezasafaei.gfx@gmail.com>

Copy link
Copy Markdown
Owner Author

Phase D verification close-out — exact draft SHA 6a22752

On 2026-10-11, all 6/6 GitHub Actions workflow runs succeeded on this exact, unmerged candidate:

Scope: Atomic current+previous minute account admission now prevents a second provider attempt one second across a minute boundary during 45s upstream timeout. 11/11 local tests against a disposable actual PostgreSQL (3 integration + 8 unit) passed with container removed; test RED before code and GREEN after.

Financial/ingress findings: Cloudflare official docs Oct 9 2026 say 10k Free neurons per account per day, but actual independent Free image account, account isolation, billing and token permissions are still unverified. Unauthenticated GET from intended Iran production VPS proved DNS/TCP/TLS only (HTTP400 with no token), not model acceptance. Nginx live read-only trust-chain audit did not establish safe real client IP; do not trust X-Forwarded-For for API throttling before approved edge ingress/WAF review. Existing per-account global five-per-day quota remains hard fail-closed. No credentials or paid inference used.

Security distinction: The default-branch GitHub Code Scanning API reported 56 already-open alerts (25 error, 31 warning); none in sampled image-specific paths. CodeQL CI success is not a zero-findings attestation. Dependabot alerts currently disabled; independent triage remains open.

NO-GO remains: independent Workers Free and dedicated account verification, least-privilege Workers AI Read/Edit token created by account owner, authorized measured single-image output and Neuron usage, trusted ingress/IP control and alerts, genuine physical mobile/manual screen reader/200% browser zoom, security acceptance, explicit owner merge and production deploy authorization. All flags default OFF, PR remains Draft, live deployed SHA f58ef7a unchanged. No FlatAI email or restrictions bypass. Full operational evidence: issue #238 comment.

Signed-off-by: alirezasafaeigfx <alirezasafaei.gfx@gmail.com>
Signed-off-by: alirezasafaeigfx <alirezasafaei.gfx@gmail.com>
Signed-off-by: alirezasafaeigfx <alirezasafaei.gfx@gmail.com>

Copy link
Copy Markdown
Owner Author

2026-10-11 owner Free confirmation + secured one-shot/keyboard acceptance checkpoint

Owner says Cloudflare account is Free. Treat this as owner plan attestation only. Independent image account isolation and a least-privilege image API token distinct from existing production chat are not verified; do not set AI_IMAGE_ACCOUNT_ISOLATED_CONFIRMED or reuse chat credentials by assumption.

Exact unmerged Draft PR #239 head: 4b54b6d57269eade6ab8adc000349ab53f084c4b.

Delivered

  • lib/ai/image-one-shot.ts, scripts/ai/image-one-shot.ts, lib/ai/image-one-shot.test.ts: one-shot synthetic image probe, absolutely gated behind per-invocation explicit opt-in, Free confirmation, independently verified separate account and token. One call maximum, sanitized errors, only metadata output, no saved image or printed credentials. Seven mock tests PASS; unconfigured CLI correctly refuses before network use. Focused TypeScript using real project config, Prettier and secret-pattern scan passed.
  • New Chromium E2E keyboard-only Tab → Space consent → Tab → Enter submit, mock 429, 320 CSS-pixel reflow/no horizontal overflow. This is not a physical phone, manual screen reader or literal browser 200% zoom test.
  • Fixed real TS2559 found on prior head cc6ed789 in Lighthouse Build by projecting the seven environment keys individually in script, not passing the full process.env. DCO-signed latest corrective commit 4b54b6d5.

Latest exact-head checks

Still NO-GO: distinct image account/token + real one-image acceptance/Neurons confirmation, trusted edge/IP controls, full independent security and manual device/zoom/screen reader, explicit owner merge and deploy authorization. Neither the image provider nor the live production chat was invoked/changed. No FlatAI email.

Copy link
Copy Markdown
Owner Author

Final exact-head CI confirmation — 2026-10-11

Latest draft head 4b54b6d57269eade6ab8adc000349ab53f084c4b: 6/6 GitHub Actions workflows completed SUCCESS on the same SHA.

This resolves the earlier TypeScript/lighthouse failure as verified on the new SHA. No real Cloudflare image inference or new image account credentials were used. PR remains Draft and unmerged; production unchanged; public enablement remains NO-GO until the separated-account and real-inference/usage acceptance plus independent release authorization.

Signed-off-by: alirezasafaeigfx <alirezasafaei.gfx@gmail.com>
Signed-off-by: alirezasafaeigfx <alirezasafaei.gfx@gmail.com>

Copy link
Copy Markdown
Owner Author

New acceptance milestone — REAL isolated Workers Free image test PASS (2026-10-11)

New owner-created image account was verified locally distinct from the chat account; image token HTTP 200 active, selected FLUX model searchable HTTP 200, and read-only AI access to old chat account denied HTTP 403. One authorized fixed-model REST request from Windows using the production adapter succeeded (1024×1024 JPEG, 22,030 bytes, 2,016 ms, process exit 0); no retries, secrets/images saved, or production changes. Local secret file image-only names, Git-ignored, ACL restricted, feature flag false. The isolated test checkout was removed afterward.

See full sanitized evidence and release gate ledger, commit f6f69412822036fab7406bc6c9bb46eaac103608, and Issue #238 acceptance note.

Still NO-GO for merge/deploy: exact actual Neuron count not dashboard-measured, token's full permission list not independently reviewed, authenticated Iran-VPS test NOT_RUN, trusted real client-IP rate limiting and manual mobile/screen reader/200% zoom review pending. Free tier is owner-attested. All image flags remain OFF. Exact-head CI running; do not conflate one-shot provider success with production rollout.

Signed-off-by: alirezasafaeigfx <alirezasafaei.gfx@gmail.com>

Copy link
Copy Markdown
Owner Author

Workers AI screenshot usage checkpoint — 2026-10-11

Owner-provided new-account Workers AI usage dashboard confirms 172.8/10,000 Neurons shown as used today, for @cf/black-forest-labs/flux-1-schnell Text-to-image (Last 24 hours chart). 1.728% consumed; 9,827.2 displayed allowance remaining by arithmetic at snapshot time. This is aggregate usage, not the measured cost of the previously successful one-shot image; no before baseline exists. Free-plan classification remains owner-attested; dashboard usage alone is not the Billing subscription readout. No API generation repeated.

Docs and evidence revised in commit 3dfa86ce2dae22d08dadca05f64c18b048d06e16, alongside sanitized Issue #238 report. Screenshot itself was not committed because it displays browser/account private identifiers. Docs Prettier, secrets scan and diff checks PASS. Current exact-head GitHub CI workflows were in progress at report time. Draft PR remains unmerged, image flag OFF; no production changes. Pending: token-scope inspection, actual account plan evidence, Iran-egress acceptance under separate authorized secure credential handling, trusted ingress/IP abuse safeguards, manual accessibility, final review and deployment approval.

Copy link
Copy Markdown
Owner Author

Owner decision supersedes this candidate — 2026-10-11

STOP / NOT APPROVED FOR PRODUCT USE. The owner explicitly clarified: Cloudflare Workers AI must be used for chat only, and FlatAI's separate image-generator track must not have been deprioritized without a product-level agreement. The official Cloudflare image spike proved API execution but has unsuitable public Free capacity: the source implementation hard-caps 5/account/day and 1/visitor/day; the Free daily Neuron allocation is also not viable at desired general-user volume.

Disposition: Close draft PR #239 without merge, deployment, feature activation, credential transfer, or branch deletion. This preserves technical audit history only, not a pending implementation candidate. Do not link /ai/image as a product feature or reuse the dedicated image Cloudflare token. Cloudflare's existing live chat integration and its separate credentials remain untouched.

Return priority to FlatAI browser-based draft PR #229 and blocker #230. Their Playwright + isolated-browser implementation remains an unmerged draft. Last controlled Linux result HTTP 403, signup_required is an unresolved provider access restriction, not a justification to declare the whole design impossible; investigate observed Windows/Linux and host distinctions through ordinary authorized means. No CAPTCHA, access-control, rate-limit or network-identity bypass; owner also directed no email to FlatAI.

This is a product-direction correction; no claim that FlatAI is publicly production-capable, free/unlimited for automated multi-user use, or permitted for browser automation until independently evidenced. Final release still requires separate owner authorization.

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.

2 participants