Skip to content

Fix parallel-branches branch middleware to run in subgraph state space#157

Merged
chris-colinsky merged 1 commit into
mainfrom
fix/parallel-branches-branch-middleware-state-space
Jun 15, 2026
Merged

Fix parallel-branches branch middleware to run in subgraph state space#157
chris-colinsky merged 1 commit into
mainfrom
fix/parallel-branches-branch-middleware-state-space

Conversation

@chris-colinsky

Copy link
Copy Markdown
Member

Summary

Branch middleware on a parallel_branches node ran the §11.4 outputs projection inside the middleware chain, so the middleware effectively operated in the parent (post-projection) state space rather than the branch subgraph's state space that pipeline-utilities §11.7 specifies. That was invisible until a branch middleware returned a cross-space partial update: RetryMiddleware re-invokes the chain rather than returning one, but FailureIsolationMiddleware's degraded_update (written in the subgraph's fields) does, and it was misapplied to the parent state and tripped extra-field validation.

The fix moves the projection outside the chain. The middleware now sees the subgraph-space partial, and the parent projection runs on whatever the chain produced: the real subgraph result on success, or a degraded_update on isolation. This matches fan_out, which already operated in subgraph space, and the spec's §11.7 model ("branch middleware wraps the branch's subgraph invocation").

Degrade-path leniency

A degraded_update that does not cover a projected outputs field now contributes nothing for that field (the parent keeps its prior or sibling-branch value) rather than raising, consistent with §11.4's buffer-then-merge model for partial contributions. A hard miss inside the failure-isolation path would defeat the purpose of the primitive.

Scope

The success path, fan_out instance middleware, and node-level placement are unchanged. The analogous fan-out degrade-contribution question (what a degraded instance contributes to a homogeneous collection, plus an extra_outputs keying detail) is a genuine spec question and is being routed to spec separately rather than decided here.

Tests

Four branch-middleware unit tests in tests/unit/test_parallel_branches.py: degrade projects through outputs, success-path guard, degrade-omit skips the contribution, and an (isolation, retry) chain where retry exhausts and isolation degrades.

Validation

  • uv run pytest tests/: 1295 passed, 376 skipped
  • uv run ruff check ., uv run pyright: clean

Branch middleware wraps the branch's subgraph invocation (per
pipeline-utilities 11.7), so it must operate in the branch subgraph's
state space. The 11.4 outputs projection ran inside the middleware
chain, so a middleware that short-circuits with a subgraph-space
partial update (notably FailureIsolation's degraded_update) had it
misapplied to the parent state and tripped extra-field validation.

Move the projection outside the chain: the middleware now sees the
subgraph-space partial, and the parent projection runs on whatever
the chain produced (the real result on success, a degraded_update on
isolation). A degraded_update that omits a projected field skips that
field rather than raising, per the 11.4 partial-contribution model.

The bug was latent because RetryMiddleware, the only branch
middleware exercised before now, re-invokes rather than returning a
cross-space update. The success path, fan-out instance middleware,
and node-level placement are unchanged.
Copilot AI review requested due to automatic review settings June 15, 2026 02:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes parallel_branches branch middleware execution so middleware runs in the branch subgraph’s state space (per pipeline-utilities §11.7) by moving the outputs projection outside the middleware chain, and adds coverage for degrade-path projection/leniency.

Changes:

  • Run branch middleware on subgraph-space partials and apply outputs projection after the middleware chain.
  • Make degrade-path projection lenient by skipping outputs fields not present in a degraded partial update.
  • Add unit tests covering degrade/success projection behavior and (isolation, retry) chain behavior; document fix in changelog.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/unit/test_parallel_branches.py Adds regression and behavior tests for branch-middleware state-space and degrade-path projection semantics.
src/openarmature/graph/parallel_branches.py Moves outputs projection outside branch middleware chain and skips missing sub-fields on degrade partials.
CHANGELOG.md Notes the bugfix and the degrade-path leniency under Unreleased “Fixed”.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/openarmature/graph/parallel_branches.py
@chris-colinsky chris-colinsky merged commit fc69aaa into main Jun 15, 2026
7 checks passed
@chris-colinsky chris-colinsky deleted the fix/parallel-branches-branch-middleware-state-space branch June 15, 2026 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants