Pipeline
pipeline
Smelt pipeline — detect, count, compact.
check(text=None, *, parsed=None)
Analyze text without transforming it.
The report carries two distinct savings figures:
strategy_estimatesmaps each registry strategy to the reduction it achieves in isolation, measured against the unmutated input. These estimates are independent and non-additive: summing them overstates the achievable gain, because strategies overlap (e.g.minifyalready removes whitespace thatcollapse_whitespacewould also target).savings_pctis the real cumulative gain — the reduction obtained by chaining the default strategy set (resolve_strategies(None, None), i.e. thesafepreset, exactly what :func:smeltapplies with no explicit strategies). It equals what a user would actually get fromsmelt(text).
original and compacted stay identical: check never transforms
its input, it only measures.
Source code in packages/axm-smelt/src/axm_smelt/core/pipeline.py
resolve_input(text, parsed)
Normalize inputs into (text, parsed).
Source code in packages/axm-smelt/src/axm_smelt/core/pipeline.py
resolve_strategies(strategies, preset)
Return strategy instances from explicit names, a preset, or the default.
Source code in packages/axm-smelt/src/axm_smelt/core/pipeline.py
smelt(text=None, strategies=None, preset=None, *, parsed=None)
Run the compaction pipeline and return a report.
Baseline for savings_pct: the pipeline's working text — the
compact serialization the strategies actually operate on. On the
text= path this is the provided raw string; on the parsed= path
it is the compact dump json.dumps(parsed, separators=(",", ":"))
(identical to report.original).
Reporting savings against the working text keeps savings_pct honest:
it measures only what the strategies achieved, never the
pretty-vs-compact gap of :func:resolve_input (which no strategy
performed). A parsed= input on which no strategy applies therefore
reports 0 — not a phantom reduction. This single honest baseline
also seeds the keep-if-reduced guard, so a strategy whose output is
heavier than the working text can never be accepted.