Optimize set
optimize_setOptimize multiple SVG documents in one call, with per-doc results, total byte savings, and a cross-doc consistency check.
Instructions
Web-optimize a SET of documents in one call: per-doc results + aggregate + verdict.
When to use: losslessly shrinking a whole multi-document system (e.g. a 12-icon set) in one
call, reading the set's total byte saving and a cross-doc consistency check. For a SINGLE
document use svg_web_optimize; to inspect the opportunities use quality_report_set.
Key params: doc_ids is a non-empty, duplicate-free set; precision / keep_ids are the SAME
arguments svg_web_optimize takes (applied to EVERY document). Each document is optimized
through the reversible pipeline, so a CHANGED document gets ONE pre-mutation snapshot +
Operation Record (ADR-004) and a no-op writes none. The whole set is rejected if ANY document
fails (no partial apply on the remainder is suppressed — earlier successful docs stay optimized
and reversible via their snapshots).
Return shape: OptimizeSetResult — per_doc (each {doc_id, result} with the standard
WebOptimizeResult), total_bytes_before / total_bytes_after / total_bytes_saved
aggregated across the set, changed_count, and consistency — the structured cross-doc verdict
computed on the PRE-optimize state (per property: agree/disagree + the differing values + which
doc_ids differ).
Example: optimize_set(["d1","d2","d3"], precision=2)
Render and look before you trust this edit: render with render_preview (or live_render_view)
and inspect the result before relying on it; restore_snapshot reverts it if it is wrong.
Risk class: medium (each document optimized reversibly; one snapshot per changed doc).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc_ids | Yes | ||
| keep_ids | No | ||
| precision | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| per_doc | Yes | ||
| consistency | Yes | Structured cross-document consistency audit over a set. One :class:`ConsistencyProperty` per audited property (``viewBox``, ``stroke_width``, ``id_naming``). ``consistent`` is True iff EVERY audited property agrees across the set. Not prose: an agent reads ``properties`` to see precisely which property disagrees and which ``doc_ids`` carry which value. | |
| changed_count | Yes | ||
| total_bytes_after | Yes | ||
| total_bytes_saved | Yes | ||
| total_bytes_before | Yes |