Changelog

On this page

All notable changes to this project are documented here. The format follows Keep a Changelog, and the project aims to follow Semantic Versioning once it reaches 1.0.

[Unreleased]

First public version, released under the MIT license. Experimental: not yet published to Hex and not yet run against a production fleet.

Added

  • Closures held in state are reported before a deploy: the plan (--dry-run, the preflight, every deploy) reads the states of the processes the deploy touches and reports each closure defined in a patched module as :closure_in_state (warn), with the process, how many processes share it, a path into the state (state.callbacks.0) and the closure's module. config :hotcode, block_on_closure_in_state: true makes it a block. Hotcode.Closures walks a term with bounds (24 levels, 20 000 terms). The struct scan's read of a state serves this check too (guide).

  • Cross-node contracts: the plan reports :cross_node_contract (warn) for every function a patch removes or adds that the app calls on other nodes with a literal module and function (:erpc, :rpc, Node.spawn, :gen_rpc), read from the compiled code (Hotcode.CrossNode) (guide).

  • config :hotcode, struct_scan: [concurrency:, suspend_concurrency:, timeout_ms:, max_processes:, only:]: how many states are read and processes suspended at a time, the read timeout, a cap that refuses a larger struct scan in the plan (:struct_scan_limit, block), and a filter on the initial-call module of the processes read for a changed struct. Measured costs in Operations.

  • Hotcode.Loader.modules/1: an application's modules including those hot deploys added (the .app list, which Application.spec/2 reads, never changes). The after_deploy/1 report carries new; the after_rollback/1 report carries modules and unloaded.

  • gen_statem hosts: the {Host, mod_key} and {Host, mod_key, state_key} entries of hosts: read the keys from the data of a {state_name, data} state; tested with a host whose code_change/4 forwards to the hosted module.

  • Fleets that are not an Erlang cluster (Hotcode.Fleet, guide): hotcode push patch.hcp --targets FILE|- (or --target URL[,key=value,...], --targets-cmd CMD; each target may carry free-form key=value metadata) surveys every node (status and dry run; nodes already on the release are skipped, so a rerun resumes), deploys --canary N nodes (or those whose metadata matches --canary-match KEY=VALUE), checks them (the node's status and --health-url), waits --soak, then the rest, --max-parallel at a time (group by group of a metadata key with --group-by KEY, --group-order), and past --max-failures halts and rolls back the nodes it changed with a rollback signed by the same keys (or --rollback-file, or --no-rollback). One JSON entry per target; the exit codes keep their meaning (3 or 4: nothing changed anywhere, 5: a target failed after something changed). hotcode status --targets reports every node. The per-node calls go through Hotcode.Fleet.Transport (Hotcode.Fleet.HTTP by default); Hotcode.Client.status/2 takes scope: :local.

  • Building without reaching a node: mix hotcode.manifest --out manifest.json [--release DIR] saves what a build or an assembled release contains (Hotcode.Manifest.from_build/2: module MD5s and code digests, application versions, OTP and Elixir, MIX_ENV, release, audience, allowed_prefixes), mix hotcode.build --manifest manifest.json builds against it, and hotcode describe manifest.json summarizes it. The node still checks the patch's base, OTP, audience, policy and signatures itself: a stale manifest can only make it refuse.

  • store_fetch: {m, f, a}: a node without a durable disk is handed, at boot, the signed envelopes it should run (Hotcode.Store.fetch_dir/1 for a directory), each verified and re-applied like a stored patch, in seq order, merged with store_dir. Operations guide: "Ephemeral disks and immutable images".

  • Waiting for old code: --wait-for-old-code 60s on push, deploy and the fleet push (?wait_for_old_code=MS, Hotcode.Rollout option :wait_for_old_code, config :hotcode, wait_for_old_code:) re-checks the processes still on a displaced version for up to that long before the preflight refuses :lingering_old_code. Hotcode.Drain (wait_for_old_code/3, lingering/1, await_children/3, await_envelope/2) for before_deploy/1 hooks that drain a Task.Supervisor or Oban queues first.

  • An agent skill in skills/hotcode/ (guide): instructions for a coding agent adopting Hotcode in a project (deployment-shape triage, audit, classification, configuration, conversions, tests, CI, first deploy, rollout), references, and scripts/audit.exs, a read-only scan of a project for hot-deploy hazards and deployment clues.

  • Rolling out to a large cluster (convergence: [mode: :spread], guide): the signed statement may carry a rollout policy ("rollout", --rollout-canary, --rollout-soak, --rollout-success, --rollout-max-unavailable, --rollout-halt-failures, --rollout-fanout, --rollout-order, --rollout-deadline, --rollout-min-canaries, --rollout-canary-match, --rollout-group-by, --require-promote), shown to co-signers as ROLLOUT: lines and shape-checked by Hotcode.Trust; absent, the statement is unchanged. The operator deploys to the canaries only (hotcode push --canary N, --canary-match KEY=VALUE; config :hotcode, canary: true). Nodes describe themselves with free-form config :hotcode, metadata: labels (Hotcode.Spread.metadata/0); Hotcode gives no key a meaning: the policy's canary may match on them, and group_by names the key whose value groups the spread (a key has no [ or ]; an {m, f, a} has 250 ms to answer, Hotcode.Spread.Metadata). The canaries soak (canary_check, sampled) and promote themselves, or wait for a signed promote (mix hotcode.promote, Hotcode.Envelope.build_promote/1, Hotcode.Trust.verify_promote/2). Every other node pulls the release from a spreader or upgraded node (its own group first), verifies it with its own loader (which also requires the policy and the expected release), runs the health check, and rolls itself back on failure; with group_by, groups go one after the other or all at once, at most max_unavailable_pct of a group (without it, of the cluster) upgrading (:global slot locks), a source serving at most fanout at once. halt_failures failures, or a canary missing its deadline, halt it, and a release that also carries auto_rollback is undone at once (the halt is the trigger; after_ms stays the deadman's deadline) with the deadman's rails. The decisions are pure functions (Hotcode.Spread.Plan), run by Hotcode.Spread on each node. Telemetry [:hotcode, :spread, :canary_passed | :promoted | :infected | :failed | :halted | :done] and the audit events :spread_*.

  • Spread: a push as the fallback of a pull. A node whose pulls reach no source push_after_attempts times (a signed policy field, --rollout-push-after, default 3), or that may not pull (spread: [pull: false]), asks for a push; one designated source pushes it (Hotcode.Spread.accept_push/3), under the same cap, fanout, group order and halt rails, and the node verifies it as it would a pull; a refused push does not mark it failed. Audit :spread_pushed.

  • Spread: a halted release can be resumed by a signed statement (hotcode resume, mix hotcode.resume, POST /resume, Hotcode.Envelope.build_resume/1, Hotcode.Trust.verify_resume/2; threshold, audience, expiry, bound to the release, its own seq as replay counter), delivered to every node under the roll lock the undo takes. Failures before it stop counting; every failed node is retried once (one that rolled the release back after its own health gate through one armed acceptance of exactly that statement, Hotcode.Loader.allow_retry/2, the replay counter untouched); refused as :undone once the undo ran, and the undo, under the same lock, skips a release a resume took out of the halt. Telemetry and audit :spread_resumed.

  • Spread: a node starts an upgrade only when it sees a strict majority of its group's known nodes, so a partitioned group never uses the cap twice; under the slot it reads its group's nodes directly, so a failure there is never missed whatever the backend.

  • The undo of a halted spread rolls holders back 8 at a time (undo_concurrency) instead of one after the other (the deadman's undo is unchanged).

  • Hotcode.Cluster.Members.Backend: the version table through a backend; the built-in one (Local) is the default, members_backend: :syn keeps it in a :syn scope (Hotcode.Cluster.Members.Syn, :syn is an optional dependency). The table also carries each node's metadata and spread role.

  • hotcode status TARGET --spread, hotcode wait TARGET [--done | --halted] --timeout --interval (exit 0 done, 5 halted, 6 still going when the time ran out: a new exit code, for wait only), hotcode promote; GET /spread and POST /promote on the HTTP endpoint; ?scope=canary on POST /deploy.

  • Tests: the state machine (spread_plan_test.exs), the policy (spread_policy_test.exs), :peer cluster tests with :syn and groups (cluster_spread_test.exs), and a simulation of 200 nodes in five groups with no BEAMs (spread_sim_test.exs, Hotcode.SpreadSim).

  • Documentation: a shorter README, with the detail moved to three new guides: Features and support, A change, step by step and Limits.

  • Testing helpers, Hotcode.Test. use Hotcode.Test replaces use ExUnit.Case and refuses async: true. It resets the loader and allows unsigned deploys for the test. Afterwards, even after a test that raised, it gives every replaced module its original binary back, unloads what the test hot-loaded, drops the Hotcode.Table tables it created and restores the application environment. build/2 compiles the next version of some modules with an external elixirc into a Hotcode.Test.Release (not loaded until deployed; cached by a hash of the sources). deploy!/2 and rollback!/1 wrap the loader. Assertions, whose failure messages name the hot-deploy mistake: assert_upgrades/3 and assert_roundtrip/3 for Hotcode.Versioned (the property form takes a StreamData generator); assert_survives_deploy/3 (same pid, migrated state, not left on old code, exact state after a rollback); assert_survives_redeploy/3 (a second deploy; names the pids the loader refuses to purge and explains :badfun); assert_table_upgrade/3 and assert_table_deploy/3 for Hotcode.Table; with_load/3 and assert_no_lost_messages/2 for traffic during a deploy; and Hotcode.Test.Cluster (:peer nodes with generated keys, a boot release, mixed versions, signed rolls). StreamData is a new optional dependency, needed only for the property form. Hotcode.Loader.reset/0 and Hotcode.Loader.pids_on_old_code/1 are now documented. Guide: Testing your hot deploys.

  • Deadman rollback: convergence: [mode: :auto] and a signed auto_rollback policy. mix hotcode.build and mix hotcode.deploy take --auto-rollback-after 120s (and --auto-rollback-attempts N), which put "auto_rollback": {"after_ms": ..., "attempts": ...} in the signed statement. Hotcode.Trust checks its shape (:bad_statement otherwise), and mix hotcode.sign shows it as an AUTO-ROLLBACK: line. In :auto mode, when a reachable node could not follow such a release by the signed deadline (its pulls failed), one coordinator undoes that release, and only it, on every node that has it, through the new Hotcode.Loader.auto_rollback/2, which checks that the stack entry carries the policy. The coordinator is the lowest node name on the head; it acts under the roll lock, with a strict majority of the cluster visible, no unreachable node on the head and nothing requiring the release. Audit :cluster_auto_rollback / :cluster_auto_rollback_failed, telemetry [:hotcode, :cluster, :auto_rollback], report().converge.state == :rolled_back. It never acts twice, never cascades, and does not retry a failure. Without a policy in the statement (the default, byte for byte as before), or in any other mode, nothing is undone automatically. Stack entries now keep requires, the policy and when they were applied (Hotcode.Loader.status/0: head, required).

  • Converging forward: convergence: [mode: :converge]. A reachable node that is behind (its release is in the history of the one release ahead of all others) pulls the signed envelopes it lacks from a random peer's store_dir and deploys them through its own loader, with its own verification (threshold, audience, expiry, replay, base, requires, policy). It does not pull during a roll, while locked or locked out, across a fork (reported as [:hotcode, :cluster, :cannot_converge]) or from an unreachable node. Bounded by attempts: 3 and backoff_ms: 5_000, then [:hotcode, :cluster, :converge_failed] with the reason; an envelope past its TTL is refused as :expired. Only nodes with a store_dir can be sources. New: Hotcode.Store.stored/0, Hotcode.Store.envelope/1, Hotcode.Cluster.Members.lineage/0, and converge: in Members.report/0. :report stays the default and changes nothing.

  • A cluster-wide version table and a convergence report. Every node keeps a table of every node and its release (Hotcode.Cluster.members/0), updated by announcements, node monitoring and a 10 s probe. A cluster left on two releases after a roll is reported (log, audit, telemetry [:hotcode, :cluster, :diverged]). Nothing is undone, and a roll in progress or an unreachable node is not judged.

  • ETS migration, Hotcode.Table. Versioned ETS tables (use Hotcode.Table, vsn: N): a deploy that changes what a table stores rewrites its rows through upgrade/2 steps, a rollback runs the newer module's downgrade/2 first, and a release with a hole in the chain or no way back is refused with the table untouched. A keeper process is the tables' heir, so a table survives its owner being replaced and is taken over by the new one.

  • Fixes for pitfalls found by review: the old version of a module is kept until the next deploy (a closure now survives one deploy); Swap re-sends the casts and messages waiting in the old process's mailbox; a process too busy to answer is migrated like any struct holder instead of skipped; before_deploy is not called while stored patches are re-applied at boot; new analyzer findings :removed_exports and :build_env; five more Credo rules.

  • Igniter installer. mix igniter.install hotcode (or mix hotcode.install) adds the node's config :hotcode for :prod to config/runtime.exs, Credo and the Hotcode plugin, and jason on Elixir 1.17. It trusts no key. Igniter is an optional dependency.

  • Credo rules for code that will be hot-deployed (Hotcode.Credo.checks/0): @on_load, :erlang.load_nif/2, a closure kept in state, ETS or a message (it fails with :badfun two deploys later), and a Hotcode.Versioned module with a missing upgrade/2 or downgrade/2 step. mix hotcode.check runs them with no configuration, and mix hotcode.credo.install adds Hotcode.Credo.Plugin to your .credo.exs. Guide: Credo rules.

  • Credo rule HC0011 Hotcode.Credo.Check.TerminateClosesSockets: a GenServer or :gen_statem terminate that closes a socket or port, or stops a listener, without calling Hotcode.Swap.swapping?/0. During a swap it would close the connection handed to the replacement process. There are now eleven rules.

  • Credo rules HC0012 to HC0017: ClosureInOptions (an fn or local capture in a child spec, start: {M, F, [fn]}, or a long-kept option: configure:, after_connect:, measurement:, tag_values:, keep:, drop:, sni_fun:, verify_fun:), LoggerLocalFilter (:logger filters and handler configs with closures), LocalAcceptLoop (an accept/recv loop that calls itself locally), DeriveOutsidePrefix (@derive of a standard-library protocol), ProcessDictionaryState (Process.put in a GenServer callback) and ApplicationStartSideEffects (tables, terms and handlers set up in Application.start/2). There are now seventeen rules. &(&1.field) is now seen as an anonymous function by HC0003 and HC0005 too.

  • Phoenix channels and LiveViews get their code_change/3: a deploy that changes a channel or LiveView module (found by the initial call Phoenix sets, {Mod, :join, 3} or {Mod, :mount, 3}, and the module's @behaviour) runs :sys.change_code on its processes, which Phoenix forwards to the module with the socket as the state, and the rollback pre-flight of a Hotcode.Versioned channel or LiveView reads that socket. No configuration. Before, these processes were only suspended and struct-migrated.

  • use Hotcode.Versioned passes its other options to use GenServer (restart:, shutdown:, id:), and gen_server: false generates only code_change/3 (for a Phoenix channel or LiveView).

  • use Hotcode.Versioned, vsn: 1 can be added to a running module in a hot deploy: the state of the unversioned release is taken as version 1 and kept, both ways. Going from an unversioned release straight to vsn: 2 or higher is still refused ({:unsupported_transition, old, new}), now with a message saying to ship vsn: 1 first.

  • mix hotcode.install adds MyAppWeb to allowed_prefixes for a :phoenix dependency too, and every other top-level namespace defined under lib/; its notice prints the list.

  • Guides: reaching the node through SSH tunnels, fly proxy, tunnel sidecars, reverse proxies, and IPv6 (getting started); the application's own priv/ and Ecto migrations with hot deploys (limits); where Hotcode does not fit; persistent_term, Agent and memory during a migration (state migration).

  • Support for Elixir 1.17 and OTP 26. The test matrix runs eight pairs from Elixir 1.17 / OTP 26 to Elixir 1.20 / OTP 29 (.github/workflows/ci.yml; locally scripts/matrix.exs). Hotcode reads JSON with the built-in JSON module from Elixir 1.18, and with the optional jason on 1.17, which your application then lists as a dependency.

  • Deploying from CI. A toolchain image (docker/Dockerfile, one tag per OTP and Elixir pair) with a stand-alone hotcode command that signs, pushes, inspects and rolls back without your project (describe, sign, push, rollback, status, gen-key). Building a patch stays mix hotcode.build, in your project. Every command takes --json (one object on stdout) and exits with a code that says what happened: 2 usage, 3 unreachable, 4 refused (nothing changed), 5 a roll that failed. --key env:NAME reads a private key from a CI secret. mix hotcode.describe prints what an envelope authorizes. New guide Deploying from CI; workflows to test the repository and publish the image.

  • Clusters. Hotcode.Rollout runs a dry run on every node before touching any, so a patch one node would refuse never runs on the others. --requires VERSION (signed in the statement) makes a release wait until an earlier one is live on every node. Hotcode.Cluster.applied?/1 gates code that writes a new message format, with expected_nodes for partitions. The guide Clusters and mixed versions explains the readers-then-writers order. Tested on real multi-node clusters and on two real mix run nodes.

  • Deploying. mix hotcode.build, sign, push, deploy, rollback and status build the smallest patch against what a live node runs, sign it, and apply it atomically with processes suspended around the switch, state migrated and everything undone on failure.

  • Authorization. Default-deny nodes that hold only Ed25519 public keys. Signed envelopes bind the patch hash, audience, expiry, a replay counter equal to the issue time, the code the patch replaces and the force / restart_apps flags. threshold signers, a module policy (allowed_prefixes; never OTP, the standard library or Hotcode), signed rollback, a kill switch, a failure lockout and an audit log.

  • HTTP endpoint. Every request is signed over a stateless single-use challenge issued by the node and verified before any body byte is read. TLS is required off loopback.

  • State migration. Changed structs are migrated automatically; Hotcode.Versioned handles changes of meaning; hand-written code_change/3 is supported; state is downgraded on rollback.

  • Restart-free replacement. Hotcode.Holder, Handoff and Swap move a process's state and open sockets to its replacement; supervision-tree changes are applied in place; Hotcode.AppSwap restarts one application (not the node) for Application.start/2, @on_load and NIF changes, behind a signed request and an operator opt-in.

  • Persistence. Patches are stored as signed envelopes, re-verified and replayed at boot, with a revoked set for rolled-back patches.

  • Rolling deploys. Node-by-node rollout with a health gate and automatic undo.

  • Extension points. Hotcode.Hook callbacks, telemetry events, health_check.

  • Dependency bumps. Hotcode.Semver classifies every application version change: patch and minor bumps are reported; a major bump, a 0.x minor bump, a downgrade or a non-semver version is blocked unless the signers accept it (--accept-major APP, part of the signed statement). The node tracks the deployed version of each application, since a running application's .app file cannot change.

  • New NIF and @on_load modules are a warning, not a block. They are loaded before the atomic batch and unloaded again if the batch fails. This is how a Rustler NIF is upgraded (a new module beside the old one, behind a facade). Only replacing a loaded one is blocked.

  • Struct migration reaches every process that holds the struct, not only those of changed modules. Processes running code under allowed_prefixes are found by inspecting their state, so LiveViews and holders of dependency structs need no configuration.

  • Examples (examples/), guides (docs/guides/), and a test suite of 521 tests and 6 doctests (with HOTCODE_REQUIRE_CLUSTER=1), including real :peer nodes, TLS, live sockets, fault injection and about 40 end-to-end tests that drive real OS processes and the real mix tasks. examples/pulse runs Phoenix Channels, Ecto/Postgres, Rust NIFs, a raw TCP feed and a second OTP application under 16 live channels, 4 TCP connections and an external checker, through ten versions: struct migration, a new NIF, two refused releases, a dependency bump, a regression, a hook veto, supervision-tree changes, a process swapped through the holder, an in-place application restart signed by two people, rollbacks, and a node restart that comes back on the deployed version.

Changed

  • The struct scan tests allowed_prefixes with the core-module set computed once per scan, not once per process: a plan over 20 000 processes went from about 1.3 s to 0.2 s.

  • The audit script of the agent skill no longer names a web framework: francis_router_is_app is gone (an edited Application module stays application_callback), and francis_handler_closure is now handler_closure, any handler fn given to a ws, sse, socket, on, subscribe or register call.

  • Hotcode.Cluster.Members.lineage/0 judges "ahead" over the distinct (version, history) pairs instead of node by node: the same answer, without a cost quadratic in the number of nodes.

  • Hotcode.Loader.status/0 also returns metadata and spread; the stack entry and head keep the signed rollout policy; Hotcode.Loader.auto_rollback/2 also accepts mode: :spread.

  • The step callback of Hotcode.Versioned and Hotcode.Table is now upgrade/2 (was migrate/2); downgrade/2 is unchanged. The number in a clause still names the version the state or row comes from: upgrade(1, s) goes v1 -> v2. Error reasons name it too ({:no_step, :upgrade, n}, {:step_failed, :upgrade, n, message}), and the testing helpers assert_migrates/3 and assert_table_migration/3 are now assert_upgrades/3 and assert_table_upgrade/3. No alias is kept: rename the clauses.

Fixed (found by the cluster and distribution end-to-end tests)

  • A deploy by node name from another machine started the CLI node under the target's address, so it only worked against a node on the same host. It now uses the address the OS routes to the target (HOTCODE_CLI_HOST overrides it).
  • mix hotcode.sign without --yes crashed instead of asking.
  • mix hotcode.deploy NODE@HOST crashed: the build and the push each started Erlang distribution, and the second start failed.
  • mix hotcode.rollback NODE@HOST crashed looking up the running version: distribution answers with the node name as an atom, HTTP with a string.

Fixed (found by the pulse example)

  • A release the node refused could run for a moment. The loader loaded the new code, then migrated tables and checked the Hotcode.Versioned chains, and only then refused and put the old code back. Processes that were not suspended (Phoenix channels calling a changed module) ran the refused code in between: examples/pulse saw 4 replies tagged with a refused release. The loader now checks tables (missing upgrade/2 or downgrade/2 clause, a step that raises, a vsn going backwards) and the states of suspended Hotcode.Versioned processes (upgrade and downgrade chains, struct reshaping) before loading anything, by running the new modules under another name on copies (lib/hotcode/shadow.ex). Such a refusal returns the same error as before, {:table_migration_failed, info} or {:migration_failed, info}, with the new field loaded: false; a refusal found after loading has loaded: true and is undone as before. The CLI exit codes do not change. Which refusals are found before loading and which only after is listed in How it works. Works on OTP 26 to 29. A module that cannot be run under another name is checked after loading instead, with a warning logged once and the telemetry event [:hotcode, :shadow, :unavailable].

  • Hotcode.Swap docs said a call waiting in the old mailbox is answered by the new process. It is run by the new process, but its caller monitors the old one and always exits with :shutdown, so the reply is lost and a caller that retries runs the request twice. The docs now say so and advise retrying only idempotent requests; test/swap_gap_test.exs asserts both the exit and the run, and its other :shutdown/:noproc assertion is now exact.

  • Docs: Hotcode.Swap.swapping?/0 is never set by Hotcode.AppSwap, whose handed-over workers are killed (their terminate/2 does not run) while the others stop normally.

  • Hotcode.Hook: hooks were skipped under interactive code loading (mix run, dev). A hook module that nothing had called yet was not loaded, function_exported?/3 returned false, and the before_deploy veto and every notification were ignored. Hook modules are now loaded before they are called.

  • Processes running a changed module's code without it being their callback module (a Phoenix channel reports {MyChannel, :join, 3} and runs inside Phoenix.Channel.Server) were not suspended across the switch, so a request handled at that moment could run half on the old code and half on the new (examples/pulse saw one reply tagged v3 in the v2 format). They are now suspended too, when they answer :sys.

  • Hotcode.Versioned: a rollback between two releases with the same vsn (only the code changed) failed with :unsupported_transition, and the loader killed the process. It is now a no-op for the state.

  • Rollback of a supervisor whose child spec changed: the supervisor re-read its init/1 while the new code was still loaded, so it kept the new spec and the child was not put back. Supervisors now re-read their children after the old code is loaded again (also when a failed deploy is undone).

  • Hotcode.Store: a patch re-applied at boot had no sequence number, so rolling it back after that boot did not revoke it, and a copy of its file put back in the store returned at the next boot.

  • The analyzer said a changed supervisor's "running children are not started or stopped", which is wrong with the default supervision: :auto. It now says they are reconciled.

Fixed (found by the ten_versions and live_edge examples)

  • A module that an earlier patch added is now attributed to its application on the node, so a later patch can remove it. Patches carry the owner of every module they ship, and the node remembers it (and restores it on rollback). Previously such a removal was skipped without a report.
  • Hotcode's own HTTP endpoint processes are never deploy targets. With carriers: [Bandit.DelegatingHandler] (needed to migrate WebSocket state held by Bandit), the process serving the deploy request was matched. It was blocked waiting for the loader, so the loader's :sys.suspend timed out and the deploy aborted. Found by the live_edge example.

Security

Three independent adversarial reviews, two by Opus. Findings fixed before this release include: a second signer who could be tricked into signing a statement for different code than the one inspected; anonymous clients able to make a node buffer large bodies or evict operators' challenges; a rolled-back patch returning from the store at the next boot; a rollback that made the next boot forget older patches; an unbounded replay counter that one dishonest signer could use to block all later deploys; and several paths in the in-place application restart that left an application stopped or a socket closed. Each has a regression test that fails without the fix. See SECURITY.md.

Fixed after the fourth review (archives, beam parsing, boot replay, build tools):

  • Envelopes and bundles are read by Hotcode.Archive, a small ustar reader, instead of :erl_tar: regular files only (no pax or GNU extension headers, links or directories), names of at most 255 bytes from A-Z a-z 0-9 . _ - + @ / with no absolute or .. path, at most 4096 entries, no name twice, checked header checksums, contents returned without copies. A 30 KB unsigned envelope with pax long-name records cost about 1.6 GB before; it is now refused in about 15 ms. Hotcode.Archive.pack/1 writes the format (archives written by earlier versions still read). the envelope reader refuses an envelope above max_envelope_bytes (default 64 MB) for every caller, including mix hotcode.sign and describe (limits).
  • Hotcode.Hash.code/1 decodes a beam's Attr chunk with :safe and never inflates a compressed term; a chunk that names atoms this VM lacks is hashed without decoding, with the same digest a VM that has the atoms computes. An unsigned 12 KB envelope created 200 000 atoms in describe, and one trusted key could do the same through a :plan; a 2 KB one inflated 2 GB. Hotcode.Bundle.unpack/1 compares the manifest with the archive's beams before parsing any of them, and refuses a gzip-compressed beam ({:bad_beam, name}). A shadow's literal table inflates within 16 MB.
  • Boot replay: a store_fetch envelope is verified before its seq orders anything; one that fails verification, does not apply or claims the seq of another envelope is skipped and reported on its own, an exact copy is skipped, and a fetched envelope never makes the node rename the files of store_dir (one unsigned file claiming seq: 1, or the same envelope twice, discarded the whole local store). fetch_dir/1 and the store read only regular files (no symlinks followed, no FIFOs or devices) up to max_envelope_bytes.
  • Hotcode.Patch filters the names a manifest lists by the module policy before making atoms of them (removed modules travel as names), and a manifest's allowed_prefixes can only narrow the builder's own config :hotcode, allowed_prefixes:, never widen it.
  • mix hotcode.install takes prefixes only from top-level defmodules under lib/, drops a namespace owned by another application (Plug, Phoenix), and names every extra prefix in a notice.
  • mix hotcode.push: --targets-cmd runs without HOTCODE_KEY, HOTCODE_COOKIE, RELEASE_COOKIE and the variables named by --key env:/--cookie env:; a --target value with whitespace or a control character is refused (a newline added targets and health= URLs); --rollback-file is checked (type, version, audience, expiry past --soak) before anything is deployed. mix hotcode.gen_key refuses to overwrite an existing NAME.pub without --force.
  • The pre-push hook works in a mktemp -d directory; the skill's audit script reads only regular files (no symlinks) and at most 2 MB of each; docker/Dockerfile takes a BASE build argument to pin the base image by digest.

Fixed after the fourth review (loader, trust, rolls, spread, HTTP):

  • The replay counter is never lowered. The retry a signed resume arms (allow_retry/2) set the counter back to that statement's seq, so an envelope a signed rollback had undone in the meantime could be applied again; the counter now keeps its highest value, in memory and on disk.
  • signatures.json holds at most 64 entries (more is {:bad_envelope, :too_many_signatures}, refused before any signature is checked), and only the first entry naming each trusted key is verified. One million copies of a trusted fingerprint in a 418 KB envelope held the loader for 40 s.
  • Every refusal Hotcode.Trust can give once one signature is checked counts toward the failure lockout (:manifest_mismatch, {:bad_beam, _}, archive errors, :issued_in_the_future), so repeated bad POST /plan calls with one key lock the node out like bad deploys (Hotcode.Guard).
  • A plan signed by fewer than threshold keys may create at most 20 000 new atoms, and all such plans together at most 100 000 per boot (config :hotcode, plan_new_atoms:): the atoms are counted from the beams' atom tables without creating any, and a plan over the limit is refused as {:too_many_atoms, count, limit}. One key could fill the atom table through the analyzer of /plan. The count reads every chunk of the beam, takes the AtU8 table as :beam_lib does (a small Atom chunk placed first no longer hides it, and a beam with two tables of one kind is refused), and counts a name shared by several beams once.
  • Every well-formed signature entry naming a trusted key is verified (at most 64 entries), so an entry inserted ahead of the real one in the unsigned signatures.json cannot hide it.
  • A public_urls entry that is not a full URL (no scheme, or not a string) is logged once at error level; the valid entries still work.
  • wait_for_old_code: every node verifies the envelope before it waits, and the wait happens before the roll lock is taken. One request key and an envelope no trusted key signed held the cluster's roll lock for up to 10 minutes.
  • A before_deploy hook that exits or throws is a veto like one that raises, and the steps of a preflight or plan after verification run guarded like a deploy's. Such a hook crashed the loader during a preflight and lost its rollback history.
  • The struct scan reads only processes that answer :sys: a Task, an Agent started with a fun or a spawned loop under allowed_prefixes is no longer sent :sys.get_state (it never answered, was counted as a holder, and every struct-changing deploy then failed {:suspend_failed, pid, :timeout}); the plan lists such processes in a :state_not_read warning. struct_scan: [max_processes:] defaults to 50 000. StructMigrator.holds?/3 walks at most 20 000 terms and 24 levels (a larger state counts as a holder).
  • The check of a Hotcode.Table on a copy runs in a task bounded by table_check: [timeout_ms: 60_000] and refuses tables above max_rows: 10_000_000; an upgrade step that never returned held the loader for good.
  • HTTP: a request signs the authority it was sent to (host:port), and a node with config :hotcode, public_urls: [...] refuses a request signed for another address, so a hostile fleet target can no longer relay an operator's signed /deploy, /rollback, /manifest or /status to another node that sets it (Hotcode.Trust.sign_request/6, header x-hotcode-authority; client and server change together). The client follows no redirect (a 3xx is an error; :httpc re-sent the signed headers to the new location), reads at most 8 MB of an answer (64 MB for /manifest, 1 MB for a fleet health check; OTP 27 and later), and warns on plain http:// off loopback. A locked node answers 423 only after authentication (anyone else gets 401), an anonymous 401 is logged at :debug (telemetry still gets it), and the Hotcode.Server docs describe the challenge scheme.
  • Spread: a node that runs the release decides with the policy of its own verified stack entry (and serves with its fanout), and rows that report different policies for the same {version, seq} halt the release ({:policy_conflict, nodes}); a forged row made an honest canary promote without the signed promote. Once a node has verified a resume, only failures and halts said under that resume count (a row claiming epoch 10^16 kept the release halted past every resume). Refused signed promotes and resumes are audited and count toward the lockout, and are refused during it; a node takes its part of a resume only while it sees the release halted, and keeps the seq of the last resume across a restart of the spread process; POST /resume and /promote answer :spread_not_running instead of a 500 while that process restarts. In mode: :spread, Loader.auto_rollback/2 undoes only an entry that carries a rollout policy (:no_rollout_policy).

Known limits

See Limits. In particular, leave allow_app_restart empty until in-place restarts have been tried against your real application tree.