Juggernaut.WarmSafe (Juggernaut v0.4.0)

Copy Markdown View Source

Warm-safe declarations (design notes §10.8, §7.5): the committed file .juggernaut.warm_safe.json, in which a person says that the boot-set mutants of a function may be settled on a warm worker instead of a fresh boot each.

A boot-set mutant's code runs while the app starts, so the boot lane gives it a fresh worker of its own. A warm worker booted with the mutant off: state boot built from the function (a value kept in :persistent_term, a parsed config) comes from the original code while the tests call the mutated one, so a warm result can differ from a real boot's. A declaration is the claim that it does not, for one function, and it must rest on evidence: pairs of a warm result and a fresh boot's result for the same mutant (pairs/2 from a recorded run, mix juggernaut.advise --verify for a sample), every one of which agreed, for the function as it is now (its hash, the hash a triage claim rests on, Juggernaut.Cache.Footprint).

A declaration's state against the code now (state/3):

  • :lapsed - the function's hash changed (or it is gone): the mutants boot fresh;
  • :unacked - the function is core and no human has acknowledged the declaration: the mutants boot fresh;
  • :applies - in the inner and gate lanes, the function's boot-set mutants that tests run again after boot are settled on a warm worker. The release lane ignores every declaration and boots each boot-set mutant fresh.

Declaring and acknowledging are a person's decisions: both are refused when JUGGERNAUT_ACTOR (or the --as name) starts with agent. A declaration made again for the same function replaces the old one and drops its acknowledgement.

Summary

Types

One mutant run both ways: warm on a worker booted with it off, fresh on a boot with it on from the start, each :killed or :survived; hash is the function's hash the run saw, source the run (or verification) it came from.

t()

Functions

declarations with the one on function acknowledged by name at at.

Whether a person has acknowledged entry.

declarations with function (a Juggernaut.Cache.Footprint.key/3) declared warm-safe on evidence (evidence/2, which must allow it), for reason, by by at at, resting on the function's current hash.

The file's text: entries sorted by function, keys in a fixed order, 2-space indent.

What pairs say about function at its current hash (core? when it is core): the pairs at that hash, how many were killed and survived both ways, the mutants that disagreed, the sources, and allows?, whether a declaration may rest on them (at least one pair, none disagreeing).

The declarations file's name, relative to the project root.

The declaration on function, or nil.

A mutant's function as declarations name it (Juggernaut.Cache.Footprint.key/3).

The pairs of older and newer together, sorted by mutant id: a pair seen again (the same mutant, function hash and outcomes) is kept once, with its newer source. Two pairs of the same mutant at the same code with different outcomes are both kept: such a mutant does not give the same result every time, and one of them disagrees.

A function key's readable name: "Elixir.A.B|f/1" is A.B.f/1.

The pairs a recorded run holds: each boot-set mutant that was tried on a warm worker (Run.boot_lane's warm) and then scored in the boot lane, both killed or survived.

The pairs of mutants from their results and the boot_lane record (Run.boot_lane, nil without one), as pairs/2.

The function key a person names: A.B.f/1 (or the key itself). nil when it is not of that form.

The declarations file of the project at root.

The declarations of the project at root: none when there is no file.

The pairs --verify recorded under store (none when there is no file).

declarations without the one on function.

The functions (Juggernaut.Cache.Footprint.key/3) whose boot-set mutants a run in lane settles on a warm worker: those of declarations that apply against hashes (each mutated file's Juggernaut.Cache.Footprint.file/1), a function counting as core when one of mutants in it is. None in the release lane.

The state of entry given the function's current hash (nil when it is gone) and whether it is core now (see the module doc).

The evidence file of mix juggernaut.advise --verify under the store store.

Writes declarations to the project at root (sorted, pretty-printed, atomic).

Records pairs under store, over those recorded before (merge/2).

Types

entry()

@type entry() :: %{required(String.t()) => term()}

pair()

@type pair() :: %{
  id: String.t(),
  function: String.t(),
  file: String.t(),
  hash: String.t(),
  warm: :killed | :survived,
  fresh: :killed | :survived,
  source: String.t()
}

One mutant run both ways: warm on a worker booted with it off, fresh on a boot with it on from the start, each :killed or :survived; hash is the function's hash the run saw, source the run (or verification) it came from.

state()

@type state() :: :applies | :unacked | :lapsed

t()

@type t() :: %Juggernaut.WarmSafe{entries: [entry()]}

Functions

ack(declarations, function, name, at)

@spec ack(t(), String.t(), String.t(), String.t()) :: t()

declarations with the one on function acknowledged by name at at.

acked?(arg1)

@spec acked?(entry()) :: boolean()

Whether a person has acknowledged entry.

declare(declarations, evidence, reason, by, at)

@spec declare(t(), map(), String.t(), String.t() | nil, String.t()) :: t()

declarations with function (a Juggernaut.Cache.Footprint.key/3) declared warm-safe on evidence (evidence/2, which must allow it), for reason, by by at at, resting on the function's current hash.

encode(warm_safe)

@spec encode(t()) :: String.t()

The file's text: entries sorted by function, keys in a fixed order, 2-space indent.

evidence(pairs, function, file, hash, core?)

@spec evidence([pair()], String.t(), String.t(), String.t() | nil, boolean()) :: map()

What pairs say about function at its current hash (core? when it is core): the pairs at that hash, how many were killed and survived both ways, the mutants that disagreed, the sources, and allows?, whether a declaration may rest on them (at least one pair, none disagreeing).

file_name()

@spec file_name() :: String.t()

The declarations file's name, relative to the project root.

find(warm_safe, function)

@spec find(t(), String.t()) :: entry() | nil

The declaration on function, or nil.

function_key(mutant)

@spec function_key(Juggernaut.Mutant.t()) :: String.t()

A mutant's function as declarations name it (Juggernaut.Cache.Footprint.key/3).

merge(older, newer)

@spec merge([pair()], [pair()]) :: [pair()]

The pairs of older and newer together, sorted by mutant id: a pair seen again (the same mutant, function hash and outcomes) is kept once, with its newer source. Two pairs of the same mutant at the same code with different outcomes are both kept: such a mutant does not give the same result every time, and one of them disagrees.

name(function)

@spec name(String.t()) :: String.t()

A function key's readable name: "Elixir.A.B|f/1" is A.B.f/1.

pairs(run, source)

@spec pairs(Juggernaut.Run.t(), String.t()) :: [pair()]

The pairs a recorded run holds: each boot-set mutant that was tried on a warm worker (Run.boot_lane's warm) and then scored in the boot lane, both killed or survived.

pairs_of(mutants, results, arg3, source)

@spec pairs_of(
  [Juggernaut.Mutant.t()],
  %{required(String.t()) => Juggernaut.Result.t()},
  map() | nil,
  String.t()
) :: [pair()]

The pairs of mutants from their results and the boot_lane record (Run.boot_lane, nil without one), as pairs/2.

parse_name(text)

@spec parse_name(String.t()) :: String.t() | nil

The function key a person names: A.B.f/1 (or the key itself). nil when it is not of that form.

path(root)

@spec path(Path.t()) :: Path.t()

The declarations file of the project at root.

read(root)

@spec read(Path.t()) :: {:ok, t()} | {:error, Juggernaut.Error.t()}

The declarations of the project at root: none when there is no file.

read_verified(store)

@spec read_verified(Path.t()) :: [pair()]

The pairs --verify recorded under store (none when there is no file).

revoke(declarations, function)

@spec revoke(t(), String.t()) :: t()

declarations without the one on function.

settled(arg1, arg2, mutants, hashes)

The functions (Juggernaut.Cache.Footprint.key/3) whose boot-set mutants a run in lane settles on a warm worker: those of declarations that apply against hashes (each mutated file's Juggernaut.Cache.Footprint.file/1), a function counting as core when one of mutants in it is. None in the release lane.

state(entry, current_hash, core?)

@spec state(entry(), String.t() | nil, boolean()) :: state()

The state of entry given the function's current hash (nil when it is gone) and whether it is core now (see the module doc).

verified_file(store)

@spec verified_file(Path.t()) :: Path.t()

The evidence file of mix juggernaut.advise --verify under the store store.

write(root, declarations)

@spec write(Path.t(), t()) :: :ok | {:error, Juggernaut.Error.t()}

Writes declarations to the project at root (sorted, pretty-printed, atomic).

write_verified(store, pairs)

@spec write_verified(Path.t(), [pair()]) :: :ok | {:error, Juggernaut.Error.t()}

Records pairs under store, over those recorded before (merge/2).