Pure capability resolver: which provider answers each need of every consumer in a stack, and which instances that makes.
Projects declare :project/provides {cap Provide} and :project/needs {cap Need} (hive-compose.schema). A consumer is a project id, a section id
<project>/<target> (it needs what its project needs) or any other id
carrying extra needs (a stack's own needs, a suite's).
Rules (decision 20261122141106-2d375c4f):
:share? true, the
default) is resolved TOGETHER: exactly one provider must satisfy all of
their ranges and pins, and they bind to its one shared instance
<provider>/<cap>. Incompatible ranges are never split into two shared
instances: they are an error naming every sharer;:share? false resolves that consumer alone, to a private instance
<provider>/<cap>@<consumer> nobody else uses;No IO and no host interop (portable Clojure, ready to become .cljc). Output is sorted and independent of input order.
Pure capability resolver: which provider answers each need of every
consumer in a stack, and which instances that makes.
Projects declare `:project/provides {cap Provide}` and `:project/needs
{cap Need}` (hive-compose.schema). A consumer is a project id, a section id
`<project>/<target>` (it needs what its project needs) or any other id
carrying extra needs (a stack's own needs, a suite's).
Rules (decision 20261122141106-2d375c4f):
- per capability, every consumer that shares (`:share?` true, the
default) is resolved TOGETHER: exactly one provider must satisfy all of
their ranges and pins, and they bind to its one shared instance
`<provider>/<cap>`. Incompatible ranges are never split into two shared
instances: they are an error naming every sharer;
- `:share? false` resolves that consumer alone, to a private instance
`<provider>/<cap>@<consumer>` nobody else uses;
- errors are Results naming the capability and the consumers:
:compose/invalid-range, :compose/invalid-version (a provider's),
:compose/unknown-consumer, :compose/conflicting-pins,
:compose/no-provider, :compose/incompatible-version,
:compose/ambiguous-provider.
No IO and no host interop (portable Clojure, ready to become .cljc).
Output is sorted and independent of input order.Addon config -> Settings. Pure: the profiles file's contents and the home directory arrive as values.
Config keys (manifest :addon/config, then config.edn :addons {"hive.compose" {..}}):
:compose/profiles [Profile ..] or {id Profile}, inline
:compose/profiles-file EDN file of the same shape
(default ~/.config/hive-mcp/compose-profiles.edn)
:compose/projects {id Project}: compose projects whose services
and native profiles are addressable as targets
(<project>/<target>)
:compose/default-ttl-minutes idle minutes before the reaper acts (default 60)
:compose/default-idle-action :stop | :down | :none (default :stop)
:compose/tick-seconds reaper period (default 60)
:compose/state-file default ~/.local/state/hive-compose/state.edn
:compose/timeout-ms per compose call (default 60000)
:compose/up-timeout-ms per up, pulls included (default 600000)
:compose/adopt? adopt running stacks of configured profiles (default true)
:compose/swarm? count agents working in a project's directories as
use of its sections (default true)
:compose/notify? shout nREPL routes and reaps to the swarm (default true)
:compose/activity #{:nrepl :published}: which new connections count as
use; :published (the host ports containers publish:
a browser, any host-side client) is opt-in (default
#{:nrepl}). A project overrides it for its sections
with :project/activity, a preset with
:profile/activity. Connections from the project's
own containers never count. :cpu (opt-in too)
counts a running service busier than
:compose/cpu-busy-percent, client or not
:compose/cpu-busy-percent CPU use, in percent of one core, above which a
service of a :cpu section is busy (default 5)
:compose/claim-ttl-minutes a claim not renewed for this long ends (default 30)
:compose/claim-max-ttl-minutes the longest wave claim (claim ttl_minutes=..) an
agent or coordinator may hold; a longer request
is refused, never clamped (default 480)
:compose/orphan-ttl-minutes idle minutes before the reaper acts on a section
whose last claim ended, when shorter than its TTL
(default 10)
:compose/program-grace-ms how long a host program is watched after its
start; one that exits within it is reported
:exited with its code and log tail (default 3000)
:compose/history-file flake history, EDN lines (default
flake-history.ednl beside the state file)
:compose/flaky flake thresholds {:window :min-runs
:flip-rate :streak}, each optional (defaults
in hive-compose.promote.flaky/defaults)
:compose/stacks [Stack ..] or {id Stack}: consumers brought up with
every capability they need (optional)
:compose/suites [Suite ..] or {id Suite}: test runners in any
language (optional)
A project places itself in the capability graph with :project/provides
{capability Provide} and :project/needs {capability Need} (see schema).
Addon config -> Settings. Pure: the profiles file's contents and the home
directory arrive as values.
Config keys (manifest `:addon/config`, then config.edn `:addons {"hive.compose" {..}}`):
:compose/profiles [Profile ..] or {id Profile}, inline
:compose/profiles-file EDN file of the same shape
(default ~/.config/hive-mcp/compose-profiles.edn)
:compose/projects {id Project}: compose projects whose services
and native profiles are addressable as targets
(`<project>/<target>`)
:compose/default-ttl-minutes idle minutes before the reaper acts (default 60)
:compose/default-idle-action :stop | :down | :none (default :stop)
:compose/tick-seconds reaper period (default 60)
:compose/state-file default ~/.local/state/hive-compose/state.edn
:compose/timeout-ms per compose call (default 60000)
:compose/up-timeout-ms per `up`, pulls included (default 600000)
:compose/adopt? adopt running stacks of configured profiles (default true)
:compose/swarm? count agents working in a project's directories as
use of its sections (default true)
:compose/notify? shout nREPL routes and reaps to the swarm (default true)
:compose/activity #{:nrepl :published}: which new connections count as
use; :published (the host ports containers publish:
a browser, any host-side client) is opt-in (default
#{:nrepl}). A project overrides it for its sections
with :project/activity, a preset with
:profile/activity. Connections from the project's
own containers never count. :cpu (opt-in too)
counts a running service busier than
:compose/cpu-busy-percent, client or not
:compose/cpu-busy-percent CPU use, in percent of one core, above which a
service of a :cpu section is busy (default 5)
:compose/claim-ttl-minutes a claim not renewed for this long ends (default 30)
:compose/claim-max-ttl-minutes the longest wave claim (claim ttl_minutes=..) an
agent or coordinator may hold; a longer request
is refused, never clamped (default 480)
:compose/orphan-ttl-minutes idle minutes before the reaper acts on a section
whose last claim ended, when shorter than its TTL
(default 10)
:compose/program-grace-ms how long a host program is watched after its
start; one that exits within it is reported
:exited with its code and log tail (default 3000)
:compose/history-file flake history, EDN lines (default
flake-history.ednl beside the state file)
:compose/flaky flake thresholds {:window :min-runs
:flip-rate :streak}, each optional (defaults
in `hive-compose.promote.flaky/defaults`)
:compose/stacks [Stack ..] or {id Stack}: consumers brought up with
every capability they need (optional)
:compose/suites [Suite ..] or {id Suite}: test runners in any
language (optional)
A project places itself in the capability graph with :project/provides
{capability Provide} and :project/needs {capability Need} (see schema).Pure data lifecycle of a stack run (hc-9): seed, migrate and reset per capability, rendered as an ordered step list a pipeline runs.
A provider declares, beside its Provide (unqualified keys, an overlay on
schema/Provide validated here, see ProvideData):
{:migrate DataCommand :seed DataCommand :reset DataCommand :reset-strategy :command|:template-db|:prefix-rotate :template {:user "postgres" :admin-db "postgres" :database-env "PGDATABASE"}}
A DataCommand is {:command [argv]} (a host process) or {:exec {:service svc
:argv [..]}} (run inside the instance's container of svc), with optional
:env and :timeout-ms.
Phases (lifecycle-plan):
:before-suite migrate, then seed (template-db: into <tenant>_tpl, then
CREATE DATABASE <tenant>_1 TEMPLATE <tenant>tpl).
:between-suites reset: :command runs :reset then :seed; :template-db
creates <tenant><n> from the template; :prefix-rotate
moves the consumer to the next tenancy prefix and seeds it.
:after :command runs :reset; the others change nothing.
Every step of a SHARED instance is scoped to one consumer's tenancy (its
prefix is in the step env, :step/scope :tenancy): a shared instance is
never reset as a whole. Volumes are never removed: a plan holding an argv
that would (-v, --volumes, down -v, volume rm|prune) is refused.
Secret references in :env stay references; a pipeline reads them at spawn.
Pure data lifecycle of a stack run (hc-9): seed, migrate and reset per
capability, rendered as an ordered step list a pipeline runs.
A provider declares, beside its Provide (unqualified keys, an overlay on
schema/Provide validated here, see `ProvideData`):
{:migrate DataCommand :seed DataCommand :reset DataCommand
:reset-strategy :command|:template-db|:prefix-rotate
:template {:user "postgres" :admin-db "postgres" :database-env "PGDATABASE"}}
A DataCommand is {:command [argv]} (a host process) or {:exec {:service svc
:argv [..]}} (run inside the instance's container of `svc`), with optional
:env and :timeout-ms.
Phases (`lifecycle-plan`):
:before-suite migrate, then seed (template-db: into <tenant>_tpl, then
CREATE DATABASE <tenant>_1 TEMPLATE <tenant>_tpl).
:between-suites reset: :command runs :reset then :seed; :template-db
creates <tenant>_<n> from the template; :prefix-rotate
moves the consumer to the next tenancy prefix and seeds it.
:after :command runs :reset; the others change nothing.
Every step of a SHARED instance is scoped to one consumer's tenancy (its
prefix is in the step env, `:step/scope :tenancy`): a shared instance is
never reset as a whole. Volumes are never removed: a plan holding an argv
that would (`-v`, `--volumes`, `down -v`, `volume rm|prune`) is refused.
Secret references in :env stay references; a pipeline reads them at spawn.Pure: an environment is {name value}, a value either a string or a secret
reference, a one-entry map naming its scheme: {:pass "<store path>"}.
A reference is read from its store only when a process is spawned (see
hive-compose.adapter.secrets). Everything else, a compose query, an error,
a rendered surface, sees it as its rendering <scheme>:<path>, never the
value it stands for.
Pure: an environment is {name value}, a value either a string or a secret
reference, a one-entry map naming its scheme: `{:pass "<store path>"}`.
A reference is read from its store only when a process is spawned (see
`hive-compose.adapter.secrets`). Everything else, a compose query, an error,
a rendered surface, sees it as its rendering `<scheme>:<path>`, never the
value it stands for.Pure: fault injection through Toxiproxy as an interposed capability (hc-12).
A Need {:via :toxiproxy} puts a proxy between its consumer and the
instance that answers it. One toxiproxy container serves a whole run:
pg:5432 in the consumer's config is right as
written) plus one internal alias, listen-alias, unique per consumer;upstream-alias
(unique per instance, so a shared and a private instance of one
capability never collide);<listen-alias>:<port> (the provider's :port)
and forwards to <upstream-alias>:<port>. Toxiproxy resolves the listen
host through Docker DNS inside its own container when the proxy is
created, to its own address on that view network, so one port serves
different consumers on different view networks. Toxiproxy must
therefore be connected to a view network before its proxies are made.Consumers with a proxy, and every suite consumer suite:<id> of a run
holding one, get TOXIPROXY_URL (the REST API, port 8474, under the
consumer's listen alias) and TOXIPROXY_PROXIES (the proxy names they may
drive, comma-separated; a suite may drive all of them).
Toxiproxy is NOT an instance of the hc-4 StackPlan: interpose-plan
names it in consumers' attach lists only, so the stack ops must bring it
up (project-spec, --wait) and run joins and install! BEFORE any
consumer starts; the hc-6 readiness gate does not see it.
plan answers the interposition; interpose-plan rewrites the hc-4
StackPlan and interpose the hc-5 Wirings with it: a consumer's attach keeps exactly the aliases it had, only the
instance answering them changes. project-spec and joins are what the
stack ops (hc-6, IStackEngine) run; hive-compose.pipeline.faults
creates the proxies through IToxiproxyClient.
Pure: fault injection through Toxiproxy as an interposed capability (hc-12).
A Need `{:via :toxiproxy}` puts a proxy between its consumer and the
instance that answers it. One toxiproxy container serves a whole run:
- it joins the consumer's view network under the ORIGINAL aliases of the
interposed instance (so `pg:5432` in the consumer's config is right as
written) plus one internal alias, `listen-alias`, unique per consumer;
- the real instance leaves that consumer's view network and is reached by
toxiproxy alone, on the run's faults network, under `upstream-alias`
(unique per instance, so a shared and a private instance of one
capability never collide);
- each proxy listens on `<listen-alias>:<port>` (the provider's `:port`)
and forwards to `<upstream-alias>:<port>`. Toxiproxy resolves the listen
host through Docker DNS inside its own container when the proxy is
created, to its own address on that view network, so one port serves
different consumers on different view networks. Toxiproxy must
therefore be connected to a view network before its proxies are made.
Consumers with a proxy, and every suite consumer `suite:<id>` of a run
holding one, get TOXIPROXY_URL (the REST API, port 8474, under the
consumer's listen alias) and TOXIPROXY_PROXIES (the proxy names they may
drive, comma-separated; a suite may drive all of them).
Toxiproxy is NOT an instance of the hc-4 StackPlan: `interpose-plan`
names it in consumers' attach lists only, so the stack ops must bring it
up (`project-spec`, --wait) and run `joins` and `install!` BEFORE any
consumer starts; the hc-6 readiness gate does not see it.
`plan` answers the interposition; `interpose-plan` rewrites the hc-4
StackPlan and `interpose` the hc-5 Wirings with it: a consumer's attach keeps exactly the aliases it had, only the
instance answering them changes. `project-spec` and `joins` are what the
stack ops (hc-6, IStackEngine) run; `hive-compose.pipeline.faults`
creates the proxies through IToxiproxyClient.Flake history -> a verdict per test case. Pure: the history rows
(CaseOutcome, see hive-compose.schema) and the thresholds arrive as
values.
A case is identified by [suite project case-id]; its rows are put in run
order (by :at, then :run/id), one per run (a run recorded twice keeps
one row), so the order the rows were appended in never matters. :error
counts as a fail; :skipped runs are counted but judged as neither.
The verdict looks at the last :window judged runs, first rule wins:
:stable no fail in the window
:regression no pass in the window, or it ends with :streak or more
consecutive fails, or with fails after passes and no flip
back (P..PF..F): failing since :since, the first run after
the last pass (its :run/sha names the commit when recorded)
:fixed :streak or more fails then :streak or more passes
closing the window, or fails then passes and no flip back
:flaky passes and fails interleaved (two flips or more) over
:min-runs runs or more, with a flip rate (status changes
between consecutive runs over runs - 1) of :flip-rate or
more
:stable otherwise (too few runs, or fails too rare to call)
OOM-killed rows (:case/oom? true, see hive-compose.promote.oom) are
never judged: they neither fail nor flip a case, so an OOM is never read
as a flake. A case with an OOM row in its last :window runs and no real
fail there is classed :oom; real fails beside it keep their own class.
Either way the report counts them under :ooms with :last-oom.
The score ranking cases is the window's flip rate, scaled down while the
window holds fewer than :min-runs runs.
Thresholds: defaults, overridden by :compose/flaky in the addon config.
Flake history -> a verdict per test case. Pure: the history rows
(CaseOutcome, see `hive-compose.schema`) and the thresholds arrive as
values.
A case is identified by [suite project case-id]; its rows are put in run
order (by `:at`, then `:run/id`), one per run (a run recorded twice keeps
one row), so the order the rows were appended in never matters. :error
counts as a fail; :skipped runs are counted but judged as neither.
The verdict looks at the last `:window` judged runs, first rule wins:
:stable no fail in the window
:regression no pass in the window, or it ends with `:streak` or more
consecutive fails, or with fails after passes and no flip
back (P..PF..F): failing since `:since`, the first run after
the last pass (its `:run/sha` names the commit when recorded)
:fixed `:streak` or more fails then `:streak` or more passes
closing the window, or fails then passes and no flip back
:flaky passes and fails interleaved (two flips or more) over
`:min-runs` runs or more, with a flip rate (status changes
between consecutive runs over runs - 1) of `:flip-rate` or
more
:stable otherwise (too few runs, or fails too rare to call)
OOM-killed rows (`:case/oom? true`, see `hive-compose.promote.oom`) are
never judged: they neither fail nor flip a case, so an OOM is never read
as a flake. A case with an OOM row in its last `:window` runs and no real
fail there is classed :oom; real fails beside it keep their own class.
Either way the report counts them under :ooms with :last-oom.
The score ranking cases is the window's flip rate, scaled down while the
window holds fewer than `:min-runs` runs.
Thresholds: `defaults`, overridden by `:compose/flaky` in the addon config.Naming of what a stack run creates, in one place so the stack plan (hc-4), the wiring (hc-5) and the ops (hc-6) always agree. The Docker name builders live in hive-compose.schema (slug, view-network, private-project); this ns delegates to them, so there is one implementation, and adds the tenancy prefix.
Naming of what a stack run creates, in one place so the stack plan (hc-4), the wiring (hc-5) and the ops (hc-6) always agree. The Docker name builders live in hive-compose.schema (slug, view-network, private-project); this ns delegates to them, so there is one implementation, and adds the tenancy prefix.
Pure: resource caps on suite runners and the diagnosis of an OOM kill (hc-16b).
mem-bytes / mem-str docker memory notation <-> bytes.capped-argv the argv a host command runs under for a cap:
systemd-run --user --scope -p MemoryMax=<cap> -p MemorySwapMax=0, or ulimit -v when no
systemd user manager answers (cap-mode).container-cap-args the docker run flags of a cap.container-finding a finding out of one docker inspect object:
State.OOMKilled true with exit 137.host-finding a finding out of a capped host run: the scope's
Result is oom-kill, or, under the ulimit
fallback, an allocation failure in the output.why-line '<service> OOM-killed at <cap>', the line the
failure bundle and compose why print.mark-run / mark-rows the finding on a run result and on its flake
history rows (:case/oom? true), so the history
classifies the run as :oom, never as a flake.A finding is {:oom/service s :oom/cap bytes-or-nil :oom/source :container|:scope|:ulimit :oom/exit n-or-nil :oom/line string} No IO here: docker inspect and systemctl answers arrive as values.
Pure: resource caps on suite runners and the diagnosis of an OOM kill
(hc-16b).
- `mem-bytes` / `mem-str` docker memory notation <-> bytes.
- `capped-argv` the argv a host command runs under for a cap:
`systemd-run --user --scope -p MemoryMax=<cap>
-p MemorySwapMax=0`, or `ulimit -v` when no
systemd user manager answers (`cap-mode`).
- `container-cap-args` the `docker run` flags of a cap.
- `container-finding` a finding out of one `docker inspect` object:
State.OOMKilled true with exit 137.
- `host-finding` a finding out of a capped host run: the scope's
Result is oom-kill, or, under the ulimit
fallback, an allocation failure in the output.
- `why-line` '<service> OOM-killed at <cap>', the line the
failure bundle and `compose why` print.
- `mark-run` / `mark-rows` the finding on a run result and on its flake
history rows (`:case/oom? true`), so the history
classifies the run as :oom, never as a flake.
A finding is
{:oom/service s :oom/cap bytes-or-nil :oom/source :container|:scope|:ulimit
:oom/exit n-or-nil :oom/line string}
No IO here: docker inspect and systemctl answers arrive as values.Processes a dead rootless dockerd left behind, and what they still hold.
Pure: every function reads a process Snapshot taken at the boundary
(hive-compose.adapter.procfs), never /proc itself.
When rootless dockerd dies (systemd-oomd killed docker.service on
2026-11-05), its containers read Exited (255) but their processes keep
running: the container's first process is reparented to the user's
systemd --user, keeps its subuid and keeps its mounts. Starting or
recreating the service then runs a second copy on the same volume in
other PID and IPC namespaces, where e.g. postgres' own data-dir interlock
cannot see the first (incident 20261105135748-5afc73f2).
A live container's process is a child of its containerd-shim, never of
systemd --user, so the parent alone tells an orphan from a live one; a
process whose cgroup names a container the daemon reports running is
still taken as owned.
Snapshot:
{:manager-pid n ; the user's systemd --user
:subuid [first count] ; the user's /etc/subuid range
:procs [{:pid :ppid :uid :name :args
:cgroup "0::/..../docker-<id>.scope"
:mounts [root ..] ; mountinfo field 4, subuid procs only
:listening #{port}}]} ; LISTEN sockets of its netns, subuid procs only
Ownership seam: container-of and owner name the container a process
belongs to; DC-SHARED (a section refusing to recreate a service another
live section holds) can map that container to its compose project and
service the same way.
Processes a dead rootless dockerd left behind, and what they still hold.
Pure: every function reads a process Snapshot taken at the boundary
(`hive-compose.adapter.procfs`), never /proc itself.
When rootless dockerd dies (systemd-oomd killed docker.service on
2026-11-05), its containers read Exited (255) but their processes keep
running: the container's first process is reparented to the user's
`systemd --user`, keeps its subuid and keeps its mounts. Starting or
recreating the service then runs a second copy on the same volume in
other PID and IPC namespaces, where e.g. postgres' own data-dir interlock
cannot see the first (incident 20261105135748-5afc73f2).
A live container's process is a child of its containerd-shim, never of
`systemd --user`, so the parent alone tells an orphan from a live one; a
process whose cgroup names a container the daemon reports running is
still taken as owned.
Snapshot:
{:manager-pid n ; the user's `systemd --user`
:subuid [first count] ; the user's /etc/subuid range
:procs [{:pid :ppid :uid :name :args
:cgroup "0::/..../docker-<id>.scope"
:mounts [root ..] ; mountinfo field 4, subuid procs only
:listening #{port}}]} ; LISTEN sockets of its netns, subuid procs only
Ownership seam: `container-of` and `owner` name the container a process
belongs to; DC-SHARED (a section refusing to recreate a service another
live section holds) can map that container to its compose project and
service the same way.Pure: the built-in otel capability and the OTLP environment a consumer is given so its telemetry is correlated by run id (and test id).
Services integrate through the OpenTelemetry protocol only: the standard OTEL_* environment variables every OTel SDK and Beyla read. No hive code ships into a service.
OTEL_RESOURCE_ATTRIBUTES is k1=v1,k2=v2 as the OTel SDK environment spec
prescribes: keys are W3C baggage tokens and are written as they are (an SDK
never decodes a key), values are percent-encoded, so a value holding ,
= % or a space survives the trip.
The otel instance joins every consumer's view network hive-<run>-<consumer>
under its service name otel (hc-5 :wiring/attach), so the container-side
endpoint is http://otel:4317; a host process reaches the published port
on localhost.
Pure: the built-in otel capability and the OTLP environment a consumer is given so its telemetry is correlated by run id (and test id). Services integrate through the OpenTelemetry protocol only: the standard OTEL_* environment variables every OTel SDK and Beyla read. No hive code ships into a service. OTEL_RESOURCE_ATTRIBUTES is `k1=v1,k2=v2` as the OTel SDK environment spec prescribes: keys are W3C baggage tokens and are written as they are (an SDK never decodes a key), values are percent-encoded, so a value holding `,` `=` `%` or a space survives the trip. The otel instance joins every consumer's view network `hive-<run>-<consumer>` under its service name `otel` (hc-5 :wiring/attach), so the container-side endpoint is `http://otel:4317`; a host process reaches the published port on localhost.
Pure: which live section holds a service another section is about to recreate (card 20261113112930-07a70584, DC-SHARED).
Several sections can run in one compose project (dc): an escala session's
section and a gestao-usuarios session's section share envoy, auth-service
and the web relay. compose has one container per service per project, so a
section that recreates a shared service takes it from under every other
section holding it: on 2026-11-13 an up with other compose files and
another HOST_GATEWAY_IP recreated dc-envoy and every page of the other
session answered 503.
A section HOLDS a service when the service is in its footprint (the
services it runs and the depends_on closure it needs, see
promote.plan/footprint). A holder is LIVE while it is active and not
orphaned (its last claim ended; the reaper takes it soon), or while it is
orphaned but something still uses it.
A call recreates a held service when:
restart recreate=true: compose recreates the named containers
whatever their config;up/switch and the call's compose inputs differ from those the
holder ran with: compose recreates a running container whose config hash
changed, and the hash follows the files, the project directory and the
interpolated env. Equal inputs leave the container as it is, so two
sections of the same project share their dependencies freely.Inputs are compared as configured, references rendered (never read): a variable that differs is a conflict even when the service does not read it, so the guard errs on the side of refusing, and the call can override.
Pure: which live section holds a service another section is about to recreate (card 20261113112930-07a70584, DC-SHARED). Several sections can run in one compose project (`dc`): an escala session's section and a gestao-usuarios session's section share envoy, auth-service and the web relay. compose has one container per service per project, so a section that recreates a shared service takes it from under every other section holding it: on 2026-11-13 an `up` with other compose files and another HOST_GATEWAY_IP recreated dc-envoy and every page of the other session answered 503. A section HOLDS a service when the service is in its footprint (the services it runs and the depends_on closure it needs, see `promote.plan/footprint`). A holder is LIVE while it is active and not orphaned (its last claim ended; the reaper takes it soon), or while it is orphaned but something still uses it. A call recreates a held service when: - it is `restart recreate=true`: compose recreates the named containers whatever their config; - it is `up`/`switch` and the call's compose inputs differ from those the holder ran with: compose recreates a running container whose config hash changed, and the hash follows the files, the project directory and the interpolated env. Equal inputs leave the container as it is, so two sections of the same project share their dependencies freely. Inputs are compared as configured, references rendered (never read): a variable that differs is a conflict even when the service does not read it, so the guard errs on the side of refusing, and the call can override.
Pure: the suite x project matrix packed into a memory budget (hc-16b), instead of run at a fixed concurrency.
Each cell weighs its runner's memory cap. pack answers waves: the cells
of one wave run together, and the caps of one wave sum to at most the
budget left once the stack itself (its capped instances) is paid for.
Cells go heaviest first, each into the first wave it fits (first-fit
decreasing), so the number of waves stays near the minimum. Ties break on
the cell key, so the answer never depends on the order the cells came in.
A cell with no cap weighs :default-mem. A cell heavier than the whole
budget can never run; pack refuses the matrix and names it rather than
run it over the budget. With no budget at all there is one wave of every
cell, capped by :max-parallel when it is given.
No IO: the budget, the stack's capped total and the caps arrive as bytes.
Pure: the suite x project matrix packed into a memory budget (hc-16b), instead of run at a fixed concurrency. Each cell weighs its runner's memory cap. `pack` answers waves: the cells of one wave run together, and the caps of one wave sum to at most the budget left once the stack itself (its capped instances) is paid for. Cells go heaviest first, each into the first wave it fits (first-fit decreasing), so the number of waves stays near the minimum. Ties break on the cell key, so the answer never depends on the order the cells came in. A cell with no cap weighs `:default-mem`. A cell heavier than the whole budget can never run; `pack` refuses the matrix and names it rather than run it over the budget. With no budget at all there is one wave of every cell, capped by `:max-parallel` when it is given. No IO: the budget, the stack's capped total and the caps arrive as bytes.
Pure planning over the active map ({profile-id Active}): which services a profile can release without starving another active profile, what a switch releases, and what the reaper reaps. Plans are vectors of Release steps.
Pure planning over the active map ({profile-id Active}): which services a
profile can release without starving another active profile, what a switch
releases, and what the reaper reaps. Plans are vectors of Release steps.Pure reads over a Profile value and the Settings that default it.
Pure reads over a Profile value and the Settings that default it.
Pure: a Program is a host process a section needs beside its containers (a
shadow-cljs watch, a JVM with an nREPL). What starts it and where its nREPL
listens are derived from the build files of its directory (facts), unless
the Program says so itself.
Facts are the parsed build files, keyed by file name:
{"shadow-cljs.edn" {..} "deps.edn" {..} "bb.edn" {..} "project.clj" true}
A Clojure kind always starts with its nREPL: shadow-cljs opens its own, a
deps.edn project runs its :nrepl alias or a plain nrepl.cmdline, lein and
babashka run their headless REPL servers.
Pure: a Program is a host process a section needs beside its containers (a
shadow-cljs watch, a JVM with an nREPL). What starts it and where its nREPL
listens are derived from the build files of its directory (`facts`), unless
the Program says so itself.
Facts are the parsed build files, keyed by file name:
{"shadow-cljs.edn" {..} "deps.edn" {..} "bb.edn" {..} "project.clj" true}
A Clojure kind always starts with its nREPL: shadow-cljs opens its own, a
deps.edn project runs its `:nrepl` alias or a plain nrepl.cmdline, lein and
babashka run their headless REPL servers.Pure: test reports folded into one shape, whatever wrote them.
A suite runner, in any language, leaves JUnit XML or TAP behind. Both fold into a Report:
{:report/format :junit | :tap | :mixed :report/cases [{:case/id :case/name :case/classname :case/status :case/time-s :case/message :case/output}] :report/totals {:passed n :failed n :error n :skipped n}}
JUnit arrives here as a plain element tree, {:tag :attrs :content :text}
(hive-compose.boundary.report owns the XML parser and the files); TAP as
text. Every entry point answers a hive-dsl Result: what cannot be read is
:report/malformed.
Pure: test reports folded into one shape, whatever wrote them.
A suite runner, in any language, leaves JUnit XML or TAP behind. Both fold
into a Report:
{:report/format :junit | :tap | :mixed
:report/cases [{:case/id :case/name :case/classname :case/status
:case/time-s :case/message :case/output}]
:report/totals {:passed n :failed n :error n :skipped n}}
JUnit arrives here as a plain element tree, {:tag :attrs :content :text}
(`hive-compose.boundary.report` owns the XML parser and the files); TAP as
text. Every entry point answers a hive-dsl Result: what cannot be read is
`:report/malformed`.Pure: resource caps of a stack's instances, their budget and admission
(hc-16a). See the Resource caps section of hive-compose.schema.
Caps of one consumer's view of an instance, per key, high to low: the
stack's :stack/resources for the capability, the consumer's Need
:resources, the Provide's :resources, :compose/default-resources.
Levels are merged low to high; an :unbounded level clears every cap
below it (a higher level may set caps again).
A shared instance serves several consumers, so it gets what each would
have had alone, combined per key by the largest: :mem and :cpus are
the maximum over the views that set them (a view with no cap has no
opinion), :jvm? is true when one says so, and the instance is unbounded
when one view is explicitly :unbounded. Hence a shared instance never
sums above the private copies it replaces (budget is monotone under
sharing).
Admission (admit) refuses with :compose/over-budget (data:
schema/OverBudget) when the capped total exceeds :stack/budget,
:compose/budget, or, for what is not yet running, the host's
MemAvailable minus :compose/host-reserve. MemAvailable comes from the
caller (port/IHostMemory), never read here.
Pure: resource caps of a stack's instances, their budget and admission (hc-16a). See the Resource caps section of `hive-compose.schema`. Caps of one consumer's view of an instance, per key, high to low: the stack's `:stack/resources` for the capability, the consumer's Need `:resources`, the Provide's `:resources`, `:compose/default-resources`. Levels are merged low to high; an `:unbounded` level clears every cap below it (a higher level may set caps again). A shared instance serves several consumers, so it gets what each would have had alone, combined per key by the largest: `:mem` and `:cpus` are the maximum over the views that set them (a view with no cap has no opinion), `:jvm?` is true when one says so, and the instance is unbounded when one view is explicitly :unbounded. Hence a shared instance never sums above the private copies it replaces (`budget` is monotone under sharing). Admission (`admit`) refuses with :compose/over-budget (data: schema/OverBudget) when the capped total exceeds `:stack/budget`, `:compose/budget`, or, for what is not yet running, the host's MemAvailable minus `:compose/host-reserve`. MemAvailable comes from the caller (port/IHostMemory), never read here.
Pure stack planning (hc-4). A Resolution (what the capability resolver
answers) becomes a StackPlan for one run: every instance under a compose
project (the provider's own name when shared, <provider>-<consumer>-<run>
when private), its services and docker labels; every consumer on its own
view network hive-<run>-<consumer>, joined by the instances it is bound to
under their original service names (network aliases, never an env
rewrite); and a start order. Then: a terraform-plan style diff against what
already runs, the image lockfile value, and a refcounted release of
instances across stacks, generalising promote.plan to services spanning
compose projects. Decision 20261122141106-2d375c4f. No IO here.
Pure stack planning (hc-4). A Resolution (what the capability resolver answers) becomes a StackPlan for one run: every instance under a compose project (the provider's own name when shared, `<provider>-<consumer>-<run>` when private), its services and docker labels; every consumer on its own view network `hive-<run>-<consumer>`, joined by the instances it is bound to under their original service names (network aliases, never an env rewrite); and a start order. Then: a terraform-plan style diff against what already runs, the image lockfile value, and a refcounted release of instances across stacks, generalising promote.plan to services spanning compose projects. Decision 20261122141106-2d375c4f. No IO here.
Pure parts of running a stack (hc-6): run ids, the ProjectSpec each instance and consumer is brought up with (see hive-compose.port/IStackEngine), readiness, what a release spares, and which runs the reaper takes.
Placement rules (decision 20261122141106-2d375c4f):
up of that project runs, so neither a second stack nor a section
ever recreates it. Its stack membership lives in the state file
(:stacks), not in labels;<provider-project>-<consumer>-<run> with
an override putting hive.run / hive.stack / hive.instance on every
service of its closure;<consumer-project>-<run>, labelled hive.run / hive.stack /
hive.consumer, attached only to its view network, its wiring env passed
into its containers by name (values stay in memory until spawn).
Instances join view networks with docker network connect --alias, so
nothing is recreated for a new consumer.Every created network and every container a stack run creates under a run-scoped compose project carries hive.run. No IO.
Pure parts of running a stack (hc-6): run ids, the ProjectSpec each instance and consumer is brought up with (see hive-compose.port/IStackEngine), readiness, what a release spares, and which runs the reaper takes. Placement rules (decision 20261122141106-2d375c4f): - a SHARED instance runs under its provider's own compose project with the project's own files and NO stack override: it is the same container a section `up` of that project runs, so neither a second stack nor a section ever recreates it. Its stack membership lives in the state file (`:stacks`), not in labels; - a PRIVATE instance runs under `<provider-project>-<consumer>-<run>` with an override putting hive.run / hive.stack / hive.instance on every service of its closure; - a CONSUMER (a project or a section with containers) runs under `<consumer-project>-<run>`, labelled hive.run / hive.stack / hive.consumer, attached only to its view network, its wiring env passed into its containers by name (values stay in memory until spawn). Instances join view networks with `docker network connect --alias`, so nothing is recreated for a new consumer. Every created network and every container a stack run creates under a run-scoped compose project carries hive.run. No IO.
Pure: the suite x project test matrix (hc-8).
A Suite (hive-compose.schema/Suite, under :compose/suites) is a test
runner in any language. compose test suites=X,Y projects=A,B runs each
selected suite against each selected project it applies to. Each such
pair is a cell.
expand-matrix suites and the two filters to the cells
[{:suite/id :project}], unknown names as Result errors.union-needs the {consumer Needs} the cells need together, for the
capability resolver (hc-3): one stack for the matrix.runner-spec what to start for one cell in one run: a container or a
host command, with the correlation env (HIVE_RUN_ID,
HIVE_SUITE_ID, HIVE_TEST_ID_PREFIX, TRACEPARENT,
BAGGAGE), the OTLP env and the reports directory.cell-result exit code + report Result + timing to the run result
the flake history (hc-13 record-run!) takes.matrix-summary the cell results folded.Services integrate only through protocols: env vars, OTLP, JUnit XML or
TAP. No IO and no randomness here: trace ids come from an injected id
source, and the OTLP env from an injected fn (hive-compose.promote.otel/otlp-env
as data). Every entry point that can fail answers a hive-dsl Result.
Pure: the suite x project test matrix (hc-8).
A Suite (`hive-compose.schema/Suite`, under `:compose/suites`) is a test
runner in any language. `compose test suites=X,Y projects=A,B` runs each
selected suite against each selected project it applies to. Each such
pair is a cell.
- `expand-matrix` suites and the two filters to the cells
[{:suite/id :project}], unknown names as Result errors.
- `union-needs` the {consumer Needs} the cells need together, for the
capability resolver (hc-3): one stack for the matrix.
- `runner-spec` what to start for one cell in one run: a container or a
host command, with the correlation env (HIVE_RUN_ID,
HIVE_SUITE_ID, HIVE_TEST_ID_PREFIX, TRACEPARENT,
BAGGAGE), the OTLP env and the reports directory.
- `cell-result` exit code + report Result + timing to the run result
the flake history (hc-13 `record-run!`) takes.
- `matrix-summary` the cell results folded.
Services integrate only through protocols: env vars, OTLP, JUnit XML or
TAP. No IO and no randomness here: trace ids come from an injected id
source, and the OTLP env from an injected fn (`hive-compose.promote.otel/otlp-env`
as data). Every entry point that can fail answers a hive-dsl Result.Pure: who works on what a section runs, which shared nREPL drives which module, and whether a section is in use.
Agents are {:agent/id :agent/status :agent/cwd}. A claim is what an agent declared itself, kept on the active entry under :claims {agent-id {:since ms :seen ms :note s :swarm? bool}}. A route is one program with an nREPL: {:dir :program/id :project :nrepl-port ..}.
Pure: who works on what a section runs, which shared nREPL drives which
module, and whether a section is in use.
Agents are {:agent/id :agent/status :agent/cwd}. A claim is what an agent
declared itself, kept on the active entry under :claims
{agent-id {:since ms :seen ms :note s :swarm? bool}}. A route is one
program with an nREPL: {:dir :program/id :project :nrepl-port ..}.Three-way merge of the persisted state {:active {id Active} :current id}.
Two addon instances can share one state file for a while: a hot remount
mounts a new instance while a call still runs on the old one. Each instance
keeps the state it last read or wrote (base). On every write it merges its
own state (mine) with what the file holds now (theirs):
Pure: no clock, no file.
Three-way merge of the persisted state {:active {id Active} :current id}.
Two addon instances can share one state file for a while: a hot remount
mounts a new instance while a call still runs on the old one. Each instance
keeps the state it last read or wrote (`base`). On every write it merges its
own state (`mine`) with what the file holds now (`theirs`):
- a key only one side changed takes that side's value, a removal included;
- a key both sides changed to two maps merges them: claims key by key the
same way, the rest from the side touched last, :last-touch the later;
- a key one side removed while the other changed it stays, because losing a
claim or a running section costs more than keeping an entry the reaper
or the forget pass drops later.
Pure: no clock, no file.Pure: a target names services or native compose profiles of a configured Project; a section is the Profile that runs exactly what it names, closed over the compose file's depends_on.
Pure: a target names services or native compose profiles of a configured Project; a section is the Profile that runs exactly what it names, closed over the compose file's depends_on.
Traces as values: the TraceQL that finds a test's traces, the Tempo HTTP
answers read into data, and the span that explains a failure. Pure: the
adapter (hive-compose.adapter.tempo) does the HTTP, this namespace only
reads and writes strings and maps.
TraceSummary (an -find-traces row):
{:trace/id "<32 hex>" :trace/root-service :trace/root-name
:trace/start-ms :trace/duration-ms}
Trace (a -trace answer):
{:trace/id "<32 hex>"
:trace/spans [{:span/id "<16 hex>" :span/parent-id "<16 hex>"|nil
:span/name :span/service :span/start-ms :span/duration-ms
:span/status :ok|:error|:unset :span/status-message
:span/attrs {"key" value}}]}
Tempo answers OTLP JSON in its protobuf mapping: ids base64 (the OTLP JSON spec says hex; both are read, told apart by their alphabet and length), int64 as strings, attribute values as {stringValue|intValue| boolValue|doubleValue|arrayValue|kvlistValue|bytesValue}, spans under resourceSpans (or the older batches) and scopeSpans (or instrumentationLibrarySpans). Span attributes and resource attributes are merged into :span/attrs, the span's own winning.
Traces as values: the TraceQL that finds a test's traces, the Tempo HTTP
answers read into data, and the span that explains a failure. Pure: the
adapter (`hive-compose.adapter.tempo`) does the HTTP, this namespace only
reads and writes strings and maps.
TraceSummary (an `-find-traces` row):
{:trace/id "<32 hex>" :trace/root-service :trace/root-name
:trace/start-ms :trace/duration-ms}
Trace (a `-trace` answer):
{:trace/id "<32 hex>"
:trace/spans [{:span/id "<16 hex>" :span/parent-id "<16 hex>"|nil
:span/name :span/service :span/start-ms :span/duration-ms
:span/status :ok|:error|:unset :span/status-message
:span/attrs {"key" value}}]}
Tempo answers OTLP JSON in its protobuf mapping: ids base64 (the OTLP
JSON spec says hex; both are read, told apart by their alphabet and
length), int64 as strings, attribute values as {stringValue|intValue|
boolValue|doubleValue|arrayValue|kvlistValue|bytesValue}, spans under
resourceSpans (or the older batches) and scopeSpans (or
instrumentationLibrarySpans). Span attributes and resource attributes are
merged into :span/attrs, the span's own winning.Pure: the failure bundle that answers compose why test=T (hc-10).
From the case that failed (a Report case, hc-8), its cell result, the
traces carrying its test id, the container logs of the run and the stack
plan, bundle folds one FailureBundle:
{:why/test-id :why/run :why/window [start-ms end-ms] :why/case {:case/id :case/name :case/status :case/message ..} :why/cell {:suite/id :project :status :exit :oom/service :oom/cap :oom/line} the :oom keys only when the runner was OOM-killed :why/failing-span {:span/id :trace/id :span/service :span/name :span/status :span/status-message :span/attrs}? :why/span-path [{:span/id :span/service :span/name :span/status :span/status-message}] root first, failing span last :why/traces [{:trace/id :trace/root-name :errors n :spans n}] :why/logs {service [line]} lines inside the window +- slack :why/plan {:run :stack :status :instances :consumers}? :why/summary "one line"}
render-markdown writes it for a human. log-window is the timestamp
filter of log lines. No IO: the pipeline (hive-compose.pipeline.why)
reads the files, queries the trace store and the engine.
Pure: the failure bundle that answers `compose why test=T` (hc-10).
From the case that failed (a Report case, hc-8), its cell result, the
traces carrying its test id, the container logs of the run and the stack
plan, `bundle` folds one FailureBundle:
{:why/test-id :why/run :why/window [start-ms end-ms]
:why/case {:case/id :case/name :case/status :case/message ..}
:why/cell {:suite/id :project :status :exit
:oom/service :oom/cap :oom/line} the :oom keys only when
the runner was OOM-killed
:why/failing-span {:span/id :trace/id :span/service :span/name
:span/status :span/status-message :span/attrs}?
:why/span-path [{:span/id :span/service :span/name :span/status
:span/status-message}] root first, failing span last
:why/traces [{:trace/id :trace/root-name :errors n :spans n}]
:why/logs {service [line]} lines inside the window +- slack
:why/plan {:run :stack :status :instances :consumers}?
:why/summary "one line"}
`render-markdown` writes it for a human. `log-window` is the timestamp
filter of log lines. No IO: the pipeline (`hive-compose.pipeline.why`)
reads the files, queries the trace store and the engine.Pure: how each consumer of a stack run is wired to the instances it resolved (hc-5, decision 20261122141106-2d375c4f).
Network aliases model: the consumer attaches only to its view network
hive-<run>-<consumer> and every bound instance joins it under its
original service names, so a provider's :env (KAFKA_BROKERS=kafka:9092)
is right as written and is never rewritten.
The env a consumer receives, layered low to high:
:env (by capability; two instances
setting one key to different values is a Result error naming both and
the key), then for each provider with :tenancy {:env VAR} VAR = the
consumer's tenancy prefix <run>.<consumer>., then extra-envs, a seq
of Env maps in order (the OTLP hook: hive-compose.promote.otel).consumer-env), per key.Secret references ({:pass path}) stay references: they are read only at
spawn (hive-compose.adapter.secrets); show a Wiring through
hive-compose.promote.env/rendered.
Pure: how each consumer of a stack run is wired to the instances it
resolved (hc-5, decision 20261122141106-2d375c4f).
Network aliases model: the consumer attaches only to its view network
`hive-<run>-<consumer>` and every bound instance joins it under its
original service names, so a provider's `:env` (`KAFKA_BROKERS=kafka:9092`)
is right as written and is never rewritten.
The env a consumer receives, layered low to high:
1. injected: each bound provider's `:env` (by capability; two instances
setting one key to different values is a Result error naming both and
the key), then for each provider with `:tenancy {:env VAR}` VAR = the
consumer's tenancy prefix `<run>.<consumer>.`, then `extra-envs`, a seq
of Env maps in order (the OTLP hook: `hive-compose.promote.otel`).
2. the consumer's own env (`consumer-env`), per key.
3. forced: HIVE_RUN_ID=<run> and hive.run.id=<run>.
Throughout, OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OTLP_PROTOCOL are
one unit (a map naming either replaces both; a result with only one is an
error), OTEL_RESOURCE_ATTRIBUTES is merged per key (comma-separated k=v,
later wins), and finally hive.run.id=<run> and HIVE_RUN_ID=<run> are
forced.
Secret references (`{:pass path}`) stay references: they are read only at
spawn (`hive-compose.adapter.secrets`); show a Wiring through
`hive-compose.promote.env/rendered`.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |