Repository navigation
feat(images): static SVG from GPT Image 2.6 with --format svg, refusing active content (#3784) - #3969
Merged
Merged
Conversation
…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>
7 of 9 tasks
schlessera
marked this pull request as ready for review
November 11, 2026 04:39
This was referenced Nov 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3784. Part of #3781.
What changed
brain image --format svgasks a GPT Image 2.6 model (gpt-image-2.6-sunburstby default, orgpt-image-2.6-flare) to author a static SVG. It sendsoutput_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'smaxquality andhighcomplexity defaults, non, and nosvgmodel-selection object. The decoded UTF-8 XML is written to a.svgpath with mimeimage/svg+xml.Refused before any request, by routing and again in
openaiProvider.generatefor direct callers:--refor--mask(the API takes SVG on generations only);--transparent(transparency is documented for png and webp only);The returned SVG is checked before anything is written (
staticSvgProblem, newsrc/svg.ts). It must decode as UTF-8 and start as an SVG document. It must not contain:<script>or<foreignObject>;iframe,object,embed,audio,video,handler,listener);on*=event-handler attribute or an@import;href,xlink:href,srcorurl()that is not a#fragment. That covers external links,data:rasters andjavascript:.A failing SVG raises a non-retryable
ImageProviderErrornaming what was found, and nothing is written.Cost: an SVG's cost is
null, both in a dry run and after the call.svg_usageauthoring tokens are billed at the authoring model's rate, which is not published here.mimeExtensionreplaces the CLI'smime.replace("image/", ""), which would have renamed an SVG to.svg+xml.Help text, README, the
image-genskill 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:
outputFormatson 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,foreignObjector<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 testinpackages/module-images: 222 pass, 0 fail. Rootbun run typecheckpasses, andbun run lintis 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.--format svgwas 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.image/svgmime and the missing guards.Mutation, restored afterwards. I made the provider ignore
staticSvgProblem's verdict (if (false && problem)). 13 tests then failed:expect(received).toBe(expected), expected 1, received 0);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 3969at head3d02d288c6a68e7089d7ff684777ee0d6b3a5ff6): 0 path or unknown collisions. Two textual overlaps ondocs/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
docs/reflect the change, or nothing documented moved.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:
--jsonenvelopes did not move, andoutputsimply ends in.svg.🤖 Generated with Claude Code