Skip to content

Stack Dependencies

A dependency links two stacks: an upstream stack and a downstream stack. When a tracked run of the upstream stack applies successfully, Zenfra starts a separate tracked run of the downstream stack. Use it when one stack builds on another, for example an application stack on top of a network stack, so that the downstream stack is planned again after every change upstream. Dependencies are available on every plan.

A dependency starts runs only. Outputs of the upstream stack are not passed to the downstream stack.

What starts a downstream run

A downstream run starts when a tracked run of the upstream stack finishes after applying. For each enabled dependency of that stack, Zenfra starts one tracked run of the downstream stack.

These upstream runs start nothing:

  • a failed or cancelled run;
  • a tracked run whose plan has no changes, because it finishes without applying;
  • a destroy run. A dependency gives no teardown order: destroying an upstream stack does not touch its downstream stacks, and their earlier runs stay as they are;
  • a proposed run, including a pull-request run and a drift check that only plans.

A drift reconcile is a tracked run, so its apply does start the downstream runs.

A downstream stack with several upstream stacks gets one run for each upstream apply. Zenfra does not wait for all upstream stacks to finish before starting a run.

A downstream run whose own plan has changes waits for approval like any other tracked run. If its plan has no changes, it finishes without applying, and the chain stops there.

Approval

A downstream run follows the downstream stack's normal approval rules: the organization's approval policy and the stack's plan policies apply to it as to any other run. Zenfra never approves it automatically. Nobody is excluded from approving it: anyone allowed to approve runs of the stack may approve it.

The run is attributed to the downstream stack's creator, or to the organization's creator when the stack's creator cannot be found. The attribution only records who the run belongs to: it gives the run no permissions of its own.

Limits

  • A stack can have at most 20 downstream stacks. Disabled dependencies count.
  • A chain can be at most 5 dependencies long. A dependency that would make a chain of enabled dependencies longer is refused when it is created or enabled. A run that would go further down a chain than 5 dependencies is skipped, with the reason depth_cap.
  • A dependency that would close a loop of enabled dependencies is refused when it is created or enabled.
  • Two stacks can have only one dependency between them, and a stack cannot depend on itself.

Enabling and disabling

A new dependency is enabled. A disabled dependency starts no runs; enabling it again does not start the runs it missed. Only upstream applies recorded at or after the dependency's last activation, which is when it was created or last enabled, start a run. Past applies are never replayed.

Disabling or removing a dependency stops the runs it has not started yet. A run that was already being created is still created, and runs that already exist are ordinary runs of the downstream stack.

Deleting stacks

  • A stack that has downstream dependencies cannot be deleted, whether they are enabled or not. Remove those dependencies first.
  • Deleting a stack removes its upstream dependencies. So a stack in the middle of a chain cannot be deleted until its downstream dependencies are removed.
  • The record of earlier downstream runs is kept: a parent run still lists the runs it started after the dependency or the downstream stack is gone.

Who may manage a dependency

A dependency is managed from its downstream stack:

  • Adding a dependency and enabling it need Write access to the downstream stack's space and Read access to the upstream stack.
  • Disabling and removing it need Write access to the downstream stack's space only.

Write access is the Write or Admin role, or a team grant that gives Write on the space. Reading a stack's dependencies needs Read access to the stack.

Visibility

You see the stack at the other end of a dependency only if you can read it. Otherwise it is returned as null, with no id, name or dispatch detail. The same rule applies on runs: a downstream run names its upstream run, stack and dependency only to a reader of the upstream stack's space, and a parent run lists only the downstream runs you can read. See Space Access.

In the dashboard

The Dependencies tab

A stack's Dependencies tab has two lists:

  • Upstream: the stacks whose successful applies start runs of this stack. With Write access to the stack's space, Add upstream stack adds one, each dependency's switch enables or disables it, and the remove button removes it. A dependency on a stack you cannot read can be disabled and removed, but not enabled.
  • Downstream: the stacks this stack starts runs of. The list is read-only: a dependency is managed on its downstream stack's Dependencies tab, which the stack's name links to.

Each dependency shows the stack at the other end, whether it is enabled, when it was last activated, its last outcome with the reason, and a View run link to the downstream run when one was created. When the downstream run's current status is available, the outcome shows it, such as Awaiting Approval or Finished; a run still queued after a start Zenfra could not confirm reads "Run created, start not confirmed". When the status is not available, the tab shows the recorded outcome. A stack you cannot read appears as "a stack you cannot see", with no name, link or outcome. The tab refreshes every 10 seconds while it is open in the browser's foreground.

Add upstream stack offers the stacks you can read, except this stack and its current upstream stacks. When the dependency is refused, for example because it would close a loop or make a chain too long, the dialog shows the reason.

On a run

A run started by a dependency carries a Dependency badge on its page and in the stack's Runs tab, whose trigger filter can select these runs. Its page says which upstream stack started it, with a View parent run link to the upstream run. When you cannot read the upstream stack's space, it says "a stack you cannot see" instead, with no link. While the run waits for approval, the page says that it follows the stack's approval rules and that anyone allowed to approve runs of the stack may approve it.

The page of an upstream run lists the runs its apply started in a Downstream runs card, with each run's stack and status. Only runs you can read are listed. A listed run whose stack you cannot read, or whose stack has been deleted, appears as "a stack you cannot see", without a link.

Outcomes

Each dependency records the outcome of its last upstream apply. It is written when that apply has been handled, and does not change afterwards:

Outcome Meaning
queued The downstream run was created. The run's current status is reported beside it.
skipped No run was started, on purpose.
failed_to_start No run could be started.

The reason, when there is one:

Reason Outcome Meaning
enqueue_unconfirmed queued The run was created, but Zenfra could not confirm it was queued to start.
child_deleted skipped, failed_to_start The downstream stack was deleted.
edge_deleted skipped The dependency was removed.
edge_disabled skipped The dependency was disabled.
edge_changed skipped The dependency changed before the run started.
depth_cap skipped The chain is deeper than 5 dependencies.
attribution_unresolved failed_to_start No user could be found to attribute the run to.
eligibility_unavailable failed_to_start The dependency could not be checked, and Zenfra gave up after retries.
integration_not_in_space failed_to_start The downstream stack's source integration cannot be used from its space.
source_unresolved failed_to_start The downstream stack's source could not be resolved.
source_config_invalid failed_to_start The downstream stack's source configuration is invalid.
run_refused failed_to_start The run was refused.
create_failed failed_to_start The run could not be created.

Alerts

On the Free plan, Zenfra sends no alert for dependencies: a downstream run is an ordinary run of its stack, with its own status, and the dependency's last outcome on the stack's Dependencies tab is the only signal of the dependency itself. On Starter and above, email notifications and webhooks cover downstream runs like any other run. A dependency that failed to start or was skipped has no run, so on every plan only its last outcome on the Dependencies tab shows it. In the API, check last_dispatch for skips and failures to start, and the downstream run or last_dispatch.child_run_status for a created run's result.

API

Action Request
List a stack's dependencies GET /api/v1/stacks/{stack_id}/dependencies
Add an upstream stack POST /api/v1/stacks/{stack_id}/dependencies with parent_stack_id
Enable or disable PUT /api/v1/stacks/{stack_id}/dependencies/{dependency_id}/enabled with enabled
Remove DELETE /api/v1/stacks/{stack_id}/dependencies/{dependency_id}
List the runs a run started GET /api/v1/runs/{run_id}/dependents

{stack_id} is always the downstream stack, except when listing: the list returns the stack's upstream dependencies (where it is the downstream stack) and its downstream dependencies (where it is the upstream stack). Each dependency has:

Field Meaning
id The dependency's id
stack {id, name} of the stack at the other end, or null when you cannot read it
enabled Whether it starts runs
activated_at When it was created or last enabled
revision, created_at, created_by Its version, creation time and creator
last_dispatch The last outcome, or null before the first one and whenever stack is null

last_dispatch has outcome, reason (empty when none), at (when the outcome was recorded) and child_run_id when a run was created. In GET /api/v1/stacks/{stack_id}/dependencies it also has child_run_status, the downstream run's current status, when you can read that run.

A refused create or enable answers 409 with one of the error codes dependency_self, dependency_exists, dependency_cycle, dependency_depth_reached and dependency_fanout_reached. Deleting a stack that has downstream dependencies answers 409 with stack_has_dependents.

A downstream run has trigger_source: dependency. Its trigger_meta holds dependency_depth (1 for a run started by a run that was not itself started by a dependency), and, when you can read the upstream stack's space, parent_run_id, parent_stack_id, edge_id (the dependency) and edge_revision.

GET /api/v1/runs/{run_id}/dependents answers {"dependents": [...]}, one item per downstream run you can read, in the order their dispatch records were created: the downstream run's id, status and created_at, and stack as {id, name} or null when you cannot read the downstream stack or it has been deleted.