Skip to content

feat(images): static SVG from GPT Image 2.6 with --format svg, refusing active content (#3784) - #3969

Merged
schlessera merged 12 commits into
mainfrom
feat/3784-image-svg
Nov 11, 2026
Merged

schlessera merged 12 commits into
mainfrom
feat/3784-image-svg

Conversation

@schlessera

@schlessera schlessera commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

Closes #3784. Part of #3781.

What changed

  • brain image --format svg asks a GPT Image 2.6 model (gpt-image-2.6-sunburst by default, or gpt-image-2.6-flare) to author a static SVG. It sends output_format: "svg" on /v1/images/generations, with modules: default image generation to GPT Image 2.6 at max quality and high complexity, with --complexity #3782's max quality and high complexity defaults, no n, and no svg model-selection object. The decoded UTF-8 XML is written to a .svg path with mime image/svg+xml.

  • Refused before any request, by routing and again in openaiProvider.generate for direct callers:

    • SVG with --ref or --mask (the API takes SVG on generations only);
    • SVG with --transparent (transparency is documented for png and webp only);
    • SVG with n above 1;
    • SVG on the 2.5 models or Gemini. The reason names the 2.6 models.
  • The returned SVG is checked before anything is written (staticSvgProblem, new src/svg.ts). It must decode as UTF-8 and start as an SVG document. It must not contain:

    • a DOCTYPE or entity declaration;
    • <script> or <foreignObject>;
    • an embedding or handler element (iframe, object, embed, audio, video, handler, listener);
    • an on*= event-handler attribute or an @import;
    • any href, xlink:href, src or url() that is not a #fragment. That covers external links, data: rasters and javascript:.

    A failing SVG raises a non-retryable ImageProviderError naming what was found, and nothing is written.

  • Cost: an SVG's cost is null, both in a dry run and after the call. svg_usage authoring tokens are billed at the authoring model's rate, which is not published here.

  • mimeExtension replaces the CLI's mime.replace("image/", ""), which would have renamed an SVG to .svg+xml.

  • Help text, README, the image-gen skill and a minor changeset document the above. Two citation ranges into the image module move with the new lines.

Why this shape

SVG support is a model capability, like GIF: outputFormats on the 2.6 pair, so routing's existing format filter narrows to them. The "generation only, n 1, no transparency" rules are request rules, refused separately.

The active-content check lives in this module. The renderer's lintDocument (packages/render-template/src/lint.ts), which it applies to local markdown SVGs, flags scripts and fetching elements. It does not flag event handlers, foreignObject or <a href> links, and the image module does not depend on render-template, so the issue's narrow fallback applies.

The check is textual and conservative. It scans the whole document, comments, CDATA and text included. A false positive refuses one picture with a reason; a false negative would write active content into the brain.

Proof

bun run test in packages/module-images: 222 pass, 0 fail. Root bun run typecheck passes, and bun run lint is clean.

Failing-first. On the GIF head (5c9595da4, since merged as #3868) with only the new tests added, the 28 new tests failed and the existing 194 passed.

  • In the CLI block, every case failed because --format svg was refused as --format must be one of png, jpeg, webp, gif (got "svg"). The refusal tests expected /SVG/ in the message (IMAGE_SVG_REFUSED). The active-content tests expected exactly one request and saw none.
  • The provider block failed on the missing format, the image/svg mime and the missing guards.

Mutation, restored afterwards. I made the provider ignore staticSvgProblem's verdict (if (false && problem)). 13 tests then failed:

  • all 12 CLI active-content cases, where the command exited 0 and wrote the file (expect(received).toBe(expected), expected 1, received 0);
  • the provider's "a direct call that gets active SVG back throws".

After restoring the file, all 222 pass.

{"version":1,"kind":"brain-check-pr-receipt","head":"3d02d288c6a68e7089d7ff684777ee0d6b3a5ff6","base":"origin/main","mode":"focused","startedAt":"2026-11-11T02:35:46.807Z","finishedAt":"2026-11-11T02:36:52.010Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":13889.765338},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":107.98370799999975},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":91.66335299999992},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":25.929393000002165},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":51071.145195000005}]}

Collisions (bun scripts/collisions.ts --json --pr 3969 at head 3d02d288c6a68e7089d7ff684777ee0d6b3a5ff6): 0 path or unknown collisions. Two textual overlaps on docs/decisions/governed-writable-workers.md, with #3393 and #3464, come only from the one-line citation range. The rest are closure-level, through shared test consumers, with #3056, #3059, #3116, #3437, #3581, #3622, #3662, #3726, #3806, #3856, #3881, #3893, #3906, #3908, #3922, #3926, #3928, #3930, #3932, #3945, #3950, #3956, #3964, #3965, #3968, #3970.

Checklist

  • Focused local preflight/behavioral receipts and complete selected hosted proof passed; actual head/base/job checkout evidence is in Proof.
  • Acceptance criteria from the issue are all met, or the gap is named below.
  • The PR and completed/advanced issues have verified release milestones under docs/process/github.md.
  • A changeset is included, or this changes nothing a consumer can see.
  • No personal data anywhere in the diff — the leakage gate covers the whole tree.
  • The integration contract index or relevant component is updated in this same commit, or nothing in the machine surface moved.
  • Docs under docs/ reflect the change, or nothing documented moved.
  • Provider history stays append-only (docs/decisions/provider-history.md): the provider-history guard passes, or nothing on a turn's path changed.

Anything left open

No live or paid call was made, so the check has only been run against stubbed SVGs, not real 2.6 output. If real authored SVGs routinely use a construct the check refuses, a follow-up can narrow it with evidence. Markup-guided edits (#3785) remain under #3781. The integration contract is unchanged: --json envelopes did not move, and output simply ends in .svg.

🤖 Generated with Claude Code

schlessera and others added 8 commits November 10, 2026 17:53
…rames and --frame-duration (#3783)

The 2.6 pair now lists gif among its output formats, so routing narrows a GIF
request to them and refuses it on 2.5 or Gemini with a reason naming the 2.6
models. --frames (2-16) and --frame-duration (20-2000 ms) are validated before
routing, need --format gif, and are sent as frame_count and frame_duration_ms
on generations and multipart edits; unset, nothing is sent and the API's
defaults apply. GIF with a mask or a transparent background is refused before
any request. A 4xx about GIF access carries a hint naming GIF preview access
instead of the generic region/verification hints. A GIF dry run prices as
unknown. The provider repeats the guards for direct callers.

Also repairs two drifted citations into the image module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ng active content (#3784)

The 2.6 pair lists svg among its output formats, so routing narrows an SVG
request to them and refuses it on 2.5 or Gemini. SVG is a single new image:
--ref, --mask, --transparent and n above 1 are refused before any request,
by routing and again by the provider for direct callers. The `svg`
authoring-model object is never sent.

The returned XML is checked before anything is written (src/svg.ts): it must
be UTF-8 and an SVG document, with no DOCTYPE or entity, script,
foreignObject, embedding element, event-handler attribute, @import, or any
href, src or url() outside the document. A failing SVG throws and nothing is
written. The mime is image/svg+xml and the file ends in .svg. Its cost is
unknown before and after the call, since svg_usage is billed at a rate not
published here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	docs/decisions/governed-writable-workers.md
#	docs/hosting/paid-cli-provider-qualification.md
#	packages/module-images/README.md
#	packages/module-images/skills/image-gen/SKILL.md
#	packages/module-images/src/cli.ts
#	packages/module-images/src/providers/openai.ts
#	packages/module-images/src/routing.ts
#	packages/module-images/src/types.ts
#	packages/module-images/tests/cli.test.ts
#	packages/module-images/tests/providers.test.ts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera schlessera added this to the 0.45.0 milestone Nov 11, 2026
@schlessera schlessera added type: feat A new capability or a change in user-visible behaviour. area: modules First-party content modules and the module seam. labels Nov 11, 2026
@schlessera
schlessera marked this pull request as ready for review November 11, 2026 04:39
@schlessera
schlessera merged commit 38aeb5f into main Nov 11, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: modules First-party content modules and the module seam. type: feat A new capability or a change in user-visible behaviour.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

modules: author static SVG with GPT Image 2.6 (--format svg)

1 participant