mix pd.reshrink (PropertyDamage v0.2.0)

View Source

Re-shrink a saved PropertyDamage failure with a larger budget.

Loads a .pd failure file and runs the shrinker again over its already-shrunk sequence, this time with a more aggressive budget, to squeeze out reductions the original run missed. This is a thin CLI shell over PropertyDamage.load_failure/1 and PropertyDamage.shrink_further/2; for anything the flags do not expose (notably a custom adapter config map), call shrink_further/2 directly.

Usage

mix pd.reshrink path/to/failure.pd [--strategy exhaustive] [--output smaller.pd]

The failure file records which model and adapter produced it, so no --model / --adapter flags are needed. Those modules must be compiled and loadable in the current project, otherwise the file cannot be decoded.

Cost

Unlike a single replay, re-shrinking exercises the System Under Test heavily: the shrinker sets up the adapter and executes many candidate sub-sequences, and a final run re-checks the result. Against a live or HTTP-backed adapter this hits the real service repeatedly. Against an in-memory adapter it is cheap.

Output

By default the task prints the reduction and writes nothing. To persist the smaller report:

  • --output PATH writes it to PATH (replacing any file already there).
  • --overwrite replaces the input file in place.

Both target an explicit location, so no file is ever clobbered silently.

Exit code

Re-shrink is not a pass/fail regression gate (that is mix pd.replay's job). The task exits zero on any successful re-shrink, whether or not the sequence got smaller: "no further reduction under this budget" is a normal outcome, not a failure. It exits non-zero only on a real error: the file failed to load, the report does not record a model/adapter, or a requested write failed.

Options

--strategy NAME       quick | thorough | exhaustive (default: thorough)
--max-iterations N     override the strategy's iteration budget
--max-time-ms N        override the strategy's time budget (milliseconds)
--output PATH          write the re-shrunk report to PATH
--overwrite            write the re-shrunk report back over the input file

The strategies set these budgets (overridable per flag above):

strategymax iterationsmax time (ms)
quick50010_000
thorough200060_000
exhaustive10_000300_000

Examples

# Try harder to shrink a failure that came out too long
mix pd.reshrink failures/currency-bug.pd --strategy exhaustive

# Re-shrink with a custom budget and save the smaller report alongside
mix pd.reshrink failures/currency-bug.pd --max-time-ms 120000 --output failures/currency-bug-min.pd

# Re-shrink in place
mix pd.reshrink failures/currency-bug.pd --overwrite