Liking cljdoc? Tell your friends :D

hive-compose.pipeline.data

Runs the data lifecycle (hc-9) of a recorded stack run: the steps hive-compose.promote.data/lifecycle-plan renders for a phase, in order, through the ports. An :exec step goes to the engine's port/IDataExec (docker exec into the instance's running container), a :host step to the runner's port/ICommandRunner in the provider project's dir, a :state step (a prefix rotation) only advances the recorded state.

The data state of a run (generations per instance and consumer) lives under [:stacks run :data] in the state, beside the run's plan, and is committed only when every step of the phase succeeded: a failed phase run again renders the same steps (template databases tolerate already exists). Volumes are never removed: the plan refuses any argv that would.

hc8 suites call run-phase! [ctx run phase] around and between suites.

Runs the data lifecycle (hc-9) of a recorded stack run: the steps
`hive-compose.promote.data/lifecycle-plan` renders for a phase, in order,
through the ports. An :exec step goes to the engine's `port/IDataExec`
(docker exec into the instance's running container), a :host step to the
runner's `port/ICommandRunner` in the provider project's dir, a :state
step (a prefix rotation) only advances the recorded state.

The data state of a run (generations per instance and consumer) lives under
`[:stacks run :data]` in the state, beside the run's plan, and is committed
only when every step of the phase succeeded: a failed phase run again
renders the same steps (template databases tolerate `already exists`).
Volumes are never removed: the plan refuses any argv that would.

hc8 suites call `run-phase!` [ctx run phase] around and between suites.
raw docstring

hive-compose.pipeline.faults

Fault injection over a stack run (hc-12): create the proxies of a faults plan in the run's toxiproxy, then add, remove, reset and list toxics on them through IToxiproxyClient.

The run's toxiproxy is recorded by install! in the ctx's :faults atom, {run {:url :proxies [name]}}: in memory only, the stack ops install again when they re-adopt a run. The hc-6 stack ops call it after bringing toxiproxy up (promote.faults/project-spec) and connecting it (promote.faults/joins), with the host URL of its published API port. :toxiproxy in the ctx, (fn [url] IToxiproxyClient), builds the client; it defaults to the HTTP adapter.

Fault injection over a stack run (hc-12): create the proxies of a faults
plan in the run's toxiproxy, then add, remove, reset and list toxics on
them through IToxiproxyClient.

The run's toxiproxy is recorded by `install!` in the ctx's `:faults`
atom, {run {:url :proxies [name]}}: in memory only, the stack ops
install again when they re-adopt a run. The hc-6 stack ops call it after
bringing toxiproxy up (`promote.faults/project-spec`) and connecting it
(`promote.faults/joins`), with the host URL of its published API port.
`:toxiproxy` in the ctx, (fn [url] IToxiproxyClient), builds the client;
it defaults to the HTTP adapter.
raw docstring

hive-compose.pipeline.flaky

Flake history: record a suite run's case outcomes, rank the cases by how intermittently they fail.

ctx keys read: :history (an IFlakeHistory), :now (0-arity epoch ms) and [:settings :compose/flaky] (thresholds, see hive-compose.promote.flaky).

Integration point for hc-8 (suites): once a runner's report is parsed, hand the run result {:run/id :suite/id :project :report Report :exit n} to record-run!; nothing else is needed for compose flaky to rank it.

Flake history: record a suite run's case outcomes, rank the cases by how
intermittently they fail.

ctx keys read: `:history` (an IFlakeHistory), `:now` (0-arity epoch ms)
and `[:settings :compose/flaky]` (thresholds, see
`hive-compose.promote.flaky`).

Integration point for hc-8 (suites): once a runner's report is parsed,
hand the run result {:run/id :suite/id :project :report Report :exit n}
to `record-run!`; nothing else is needed for `compose flaky` to rank it.
raw docstring

hive-compose.pipeline.ops

Section and profile operations over a context:

{:engine IComposeEngine :runner IProgramRunner ; optional: host programs :settings Settings :state (atom {:active {id Active} :current id-or-nil}) :now (fn [] epoch-ms) :save! (fn [persisted-state] Result)} ; optional

A subject is a Profile: a configured preset (lookup) or a section resolved from a target against the configured compose projects (resolve-target). Every operation answers a Result (reap! and adopt! answer reports). The active map changes only after the engine confirmed the action.

A section also holds the host programs paired with its services: they start once its containers are up and stop when the last section holding them is released. A program that fails to start is reported, never fatal.

Section and profile operations over a context:

  {:engine   IComposeEngine
   :runner   IProgramRunner                   ; optional: host programs
   :settings Settings
   :state    (atom {:active {id Active} :current id-or-nil})
   :now      (fn [] epoch-ms)
   :save!    (fn [persisted-state] Result)}   ; optional

A subject is a Profile: a configured preset (`lookup`) or a section resolved
from a target against the configured compose projects (`resolve-target`).
Every operation answers a Result (reap! and adopt! answer reports). The
active map changes only after the engine confirmed the action.

A section also holds the host programs paired with its services: they start
once its containers are up and stop when the last section holding them is
released. A program that fails to start is reported, never fatal.
raw docstring

hive-compose.pipeline.orphans

The guard up, switch and restart pass before they start or recreate anything: refuse while processes a dead rootless dockerd left behind still hold a volume or a host port of the services about to start (incident 20261105135748-5afc73f2: a recreated postgres ran beside the orphan postmaster on the same data dir).

The guard runs only when the context has a process table (:processes, IProcessTable) and the engine answers IContainerOwnership. When the process table or the engine cannot answer, the guard says so in the result (:orphan-check) and lets the call through: it never blocks on its own failure. allow? (the tool's allow_orphans) lets a call through that it would refuse, naming what it overrode.

The guard `up`, `switch` and `restart` pass before they start or recreate
anything: refuse while processes a dead rootless dockerd left behind still
hold a volume or a host port of the services about to start (incident
20261105135748-5afc73f2: a recreated postgres ran beside the orphan
postmaster on the same data dir).

The guard runs only when the context has a process table (:processes,
IProcessTable) and the engine answers IContainerOwnership. When the
process table or the engine cannot answer, the guard says so in the
result (:orphan-check) and lets the call through: it never blocks on its
own failure. `allow?` (the tool's allow_orphans) lets a call through
that it would refuse, naming what it overrode.
raw docstring

hive-compose.pipeline.ownership

The guard up, switch and restart pass before they create or recreate containers: refuse when a service the call would recreate is held by another live section, naming the section and the agents that own it (card 20261113112930-07a70584). The decision is promote.ownership/conflicts; this namespace only gathers its inputs: the services the call touches and the active map.

allow? (the tool's allow_shared) lets a refused call through and the answer names what it overrode. A failure to work out the services (compose rejects the config) is reported under :ownership-check and never blocks: the call itself will meet the same failure.

The guard `up`, `switch` and `restart` pass before they create or recreate
containers: refuse when a service the call would recreate is held by
another live section, naming the section and the agents that own it (card
20261113112930-07a70584). The decision is `promote.ownership/conflicts`;
this namespace only gathers its inputs: the services the call touches
and the active map.

`allow?` (the tool's allow_shared) lets a refused call through and the
answer names what it overrode. A failure to work out the services (compose
rejects the config) is reported under :ownership-check and never blocks:
the call itself will meet the same failure.
raw docstring

hive-compose.pipeline.restart

Recycling a section's services in place. Unlike down/stop, a restart takes nothing away from another active section that needs the service, so it runs even when the service is shared: a container whose process died inside (a dev server under a file watcher) is recycled through the tool instead of by hand.

Recycling a section's services in place. Unlike down/stop, a restart takes
nothing away from another active section that needs the service, so it
runs even when the service is shared: a container whose process died
inside (a dev server under a file watcher) is recycled through the tool
instead of by hand.
raw docstring

hive-compose.pipeline.stacks

Stack runs over a context (the one hive-compose.pipeline.ops takes; its engine must satisfy hive-compose.port/IStackEngine):

stack-up! resolve (hc-3) -> plan (hc-4) -> wiring (hc-5) -> view networks -> instances in start order, each up --waited and health-gated -> each instance joins its consumers' view networks under its aliases -> consumers, each only once every instance it binds is healthy, on its view network alone, with its wiring env (secrets read at spawn). stack-down! consumers, then the run's view networks (which detaches shared instances from them), then instances in reverse start order releasing only what no other live run, active section, or the world before this run keeps (hc-4 instance-release). Never volumes. stack-status what each run's containers are doing now. plan hc-4 plan-diff of a stack against what runs. reap! takes down idle, unclaimed runs, as the reaper does sections. claim!/release-claim! agents hold a run (target=stack:<run>).

Runs persist under :stacks {run entry} in the state, beside :active. An entry: {:stack/id :run :started-at :last-touch :plan StackPlan :networks [name] :consumers {consumer {:compose-project :services}} :status :up|:partial :claims {agent Claim} :orphaned-at ms}. What ran before the runs is global, not per run: :preexisting {provider-project #{service}} beside :stacks (run/mark-preexisting, run/reconcile-preexisting).

stack-up!, stack-down!, reap!, claim! and release-claim! are serialized on one lock per state: the monitor of the context's state atom (a reloaded context shares the atom, so it shares the lock). Each holds it across its plan, its engine IO and its state writes, so no down plans a release an up then relies on, and no probe reads a world another stack op is changing. Reads (stack-status, plan) take no lock.

Stack runs over a context (the one `hive-compose.pipeline.ops` takes; its
engine must satisfy `hive-compose.port/IStackEngine`):

  stack-up!     resolve (hc-3) -> plan (hc-4) -> wiring (hc-5) -> view
                networks -> instances in start order, each `up --wait`ed
                and health-gated -> each instance joins its consumers'
                view networks under its aliases -> consumers, each only
                once every instance it binds is healthy, on its view
                network alone, with its wiring env (secrets read at spawn).
  stack-down!   consumers, then the run's view networks (which detaches
                shared instances from them), then instances in reverse
                start order releasing only what no other live run, active
                section, or the world before this run keeps (hc-4
                instance-release). Never volumes.
  stack-status  what each run's containers are doing now.
  plan          hc-4 plan-diff of a stack against what runs.
  reap!         takes down idle, unclaimed runs, as the reaper does sections.
  claim!/release-claim!  agents hold a run (`target=stack:<run>`).

Runs persist under `:stacks {run entry}` in the state, beside `:active`.
An entry: {:stack/id :run :started-at :last-touch :plan StackPlan
:networks [name] :consumers {consumer {:compose-project :services}}
:status :up|:partial :claims {agent Claim} :orphaned-at ms}. What ran
before the runs is global, not per run: `:preexisting {provider-project
#{service}}` beside `:stacks` (`run/mark-preexisting`,
`run/reconcile-preexisting`).

stack-up!, stack-down!, reap!, claim! and release-claim! are serialized
on one lock per state: the monitor of the context's state atom (a
reloaded context shares the atom, so it shares the lock). Each holds it
across its plan, its engine IO and its state writes, so no down plans a
release an up then relies on, and no probe reads a world another stack
op is changing. Reads (stack-status, plan) take no lock.
raw docstring

hive-compose.pipeline.suites

The suite x project matrix run (hc-8), over the context hive-compose.pipeline.ops takes, plus :suite-runner (a hive-compose.port/ISuiteRunner).

test! expand the matrix (promote.suite), bring up ONE stack for it, the union of the projects under test and the suites' own needs (hc-6 stack-up! with :extra), run every cell's runner through ISuiteRunner under its resource caps (hc-16b), read its reports (boundary.report), fold the cell result, record it in the flake history (hc-13, when present), then the matrix summary. A matrix that passed is taken down unless :keep-up?; a failed one stays up for inspection (the reaper TTL still applies, and stack-down run=<run> releases it).

Optional context keys: :id-source (fn [n-bytes]) -> 2n hex chars for trace ids, :rand-hex (0-arity, 6 hex chars) for run ids, :state-dir (default: the state file's directory), :otlp-env (default promote.otel/otlp-env when the stack binds an otel instance, else none), :record-run! (fn [ctx cell-result]) -> Result, the flake history (hc-13), none when absent, :data-phase! (fn [ctx run phase]) (hc-9 pipeline.data/run-phase!), and :default-resources, the caps of a suite that declares none (:compose/default-resources). Each cell's full result goes to <state>/runs/<run>/<suite>/<project>/result.edn and the matrix answer to <state>/runs/<run>/summary.edn (boundary.runs).

Every entry point answers a Result and never throws. An interrupt (a cancelled call) stops the matrix: the cells not yet started answer :compose/interrupted, and the flag is restored for the caller.

The suite x project matrix run (hc-8), over the context `hive-compose.pipeline.ops`
takes, plus `:suite-runner` (a `hive-compose.port/ISuiteRunner`).

  test!  expand the matrix (promote.suite), bring up ONE stack for it, the
         union of the projects under test and the suites' own needs
         (hc-6 stack-up! with :extra), run every cell's runner through
         ISuiteRunner under its resource caps (hc-16b), read its reports
         (boundary.report), fold the cell result, record it in the flake
         history (hc-13, when present), then the matrix summary. A matrix
         that passed is taken down unless :keep-up?; a failed one stays up
         for inspection (the reaper TTL still applies, and `stack-down
         run=<run>` releases it).

Optional context keys: `:id-source` (fn [n-bytes]) -> 2n hex chars for
trace ids, `:rand-hex` (0-arity, 6 hex chars) for run ids, `:state-dir`
(default: the state file's directory), `:otlp-env` (default
`promote.otel/otlp-env` when the stack binds an otel instance, else none),
`:record-run!` (fn [ctx cell-result]) -> Result, the flake history
(hc-13), none when absent, `:data-phase!` (fn [ctx run phase]) (hc-9
`pipeline.data/run-phase!`), and `:default-resources`, the caps of a suite
that declares none (`:compose/default-resources`).
Each cell's full result goes to `<state>/runs/<run>/<suite>/<project>/result.edn`
and the matrix answer to `<state>/runs/<run>/summary.edn` (boundary.runs).

Every entry point answers a Result and never throws. An interrupt (a
cancelled call) stops the matrix: the cells not yet started answer
:compose/interrupted, and the flag is restored for the caller.
raw docstring

hive-compose.pipeline.swarm

Swarm work on the sections the addon runs, over the ops context plus:

{:swarm ISwarm ; optional: live agents and notices :activity IActivity} ; optional: connections to local ports

  • routes: which shared nREPL drives which module (a program directory).
  • claims: an agent declares it works on a section; a claim keeps the section alive while renewed, and ends after the claim TTL or when the agent leaves the swarm.
  • observe!: one pass of the reaper. It expires claims, counts as use the claims that hold, the agents whose cwd lies in the section's project and the connections newly opened to its nREPL (and, opt-in per project with :project/activity, published) ports, the connections its own containers hold to those left out, and (opt-in with :cpu) its services busier than :compose/cpu-busy-percent, touches what is in use, records which source counted (:usage :sources), marks a section whose last claim ended orphaned (reaped after the shorter orphan TTL), and tells each agent once which shared nREPL drives the module it works in.

Nothing here starts a JVM for an agent: routes point at the programs the sections run, so a swarm shares one nREPL per module instead of each agent booting its own.

Swarm work on the sections the addon runs, over the ops context plus:

  {:swarm    ISwarm      ; optional: live agents and notices
   :activity IActivity}  ; optional: connections to local ports

* routes: which shared nREPL drives which module (a program directory).
* claims: an agent declares it works on a section; a claim keeps the
  section alive while renewed, and ends after the claim TTL or when the
  agent leaves the swarm.
* observe!: one pass of the reaper. It expires claims, counts as use the
  claims that hold, the agents whose cwd lies in the section's project and
  the connections newly opened to its nREPL (and, opt-in per project with
  :project/activity, published) ports, the connections its own containers
  hold to those left out, and (opt-in with :cpu) its services busier than
  :compose/cpu-busy-percent, touches what is in use, records which source
  counted (:usage :sources), marks a section whose last claim ended orphaned
  (reaped after the shorter orphan TTL), and tells each agent once which
  shared nREPL drives the module it works in.

Nothing here starts a JVM for an agent: routes point at the programs the
sections run, so a swarm shares one nREPL per module instead of each agent
booting its own.
raw docstring

hive-compose.pipeline.why

compose why test=T [run=R] (hc-10): find the failed case in the run results hc-8 wrote, read the traces carrying its test id (ITraceQuery), the container logs of its run in the case's window (the engine's -logs), and the stack plan, fold them into a FailureBundle (hive-compose.promote.why) and write it beside the run: <state-dir>/runs/<run>/why/<case>.md and .edn.

ctx: the ops/stacks context (:engine :settings :state) plus :trace-query an ITraceQuery (e.g. hive-compose.adapter.tempo/make-query); absent, the bundle has no traces and says so :state-dir where runs/ lives; default the state file's directory :note! optional (fn [{:test-id :run :summary :files}]) told about every bundle written (a memory note); its failure is reported, never thrown :why/tail log lines read per compose project (default 2000) :why/slack-ms window slack (default why/default-slack-ms)

`compose why test=T [run=R]` (hc-10): find the failed case in the run
results hc-8 wrote, read the traces carrying its test id (ITraceQuery),
the container logs of its run in the case's window (the engine's `-logs`),
and the stack plan, fold them into a FailureBundle
(`hive-compose.promote.why`) and write it beside the run:
<state-dir>/runs/<run>/why/<case>.md and .edn.

ctx: the ops/stacks context (:engine :settings :state) plus
  :trace-query  an ITraceQuery (e.g. `hive-compose.adapter.tempo/make-query`);
                absent, the bundle has no traces and says so
  :state-dir    where runs/ lives; default the state file's directory
  :note!        optional (fn [{:test-id :run :summary :files}]) told about
                every bundle written (a memory note); its failure is
                reported, never thrown
  :why/tail     log lines read per compose project (default 2000)
  :why/slack-ms window slack (default `why/default-slack-ms`)
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close