Repository navigation
Description
Overview
The playbook engine's for_each (packages/core/src/playbook/actions.rs) applies the same action to every item in a resolved collection — one write per item (e.g. reassigning each incomplete task to a successor cycle). There is no primitive for the opposite shape: reducing a collection down to a single aggregate value (a sum, count, or similar) and writing that one result onto a different node. CEL itself, as wired into this engine (packages/core/src/playbook/cel.rs's build_condition_context), only registers three scalar helper functions (days_since, days_until, today) — no aggregate function exists anywhere in the current condition/action surface.
Problem Statement
A concrete, motivating case: a Cycle showing a running total of the estimate points across all Issues currently assigned to it (a very Linear-like affordance) needs something that sums a numeric field across every node related to the Cycle and writes that single number back onto the Cycle. Nothing in the current Play model can express this — for_each iterates and mutates per-item, it cannot collapse a collection into one derived value. Confirmed via inspection of actions.rs (for_each execution, ~line 633 onward) and cel.rs's registered function set (~lines 344-346) — no aggregation path exists today, and no ADR or architecture doc names this as a deferred/known gap.
Proposed Solution
Add an aggregation-capable action kind (exact shape to be decided during implementation, but should at minimum support sum and count over a resolved collection, keyed by a field path on each collection item), executed similarly to for_each but producing a single scalar result instead of iterating actions — then written onto a target field via the existing action-writing mechanism.
Two implementation shapes worth weighing during design:
- A new
ActionKindvariant (e.g.Aggregate) parallel tofor_each, resolving a collection the same wayfor_eachdoes, then reducing it (sum/count/etc.) rather than iterating an action per item. - A CEL-level aggregate function (e.g. registering a
sum(collection, field)custom function alongsidedays_since/days_until/today), usable inside a condition or action-value expression, letting existing action plumbing write the computed result without a newActionKind.
Option 2 may be the lighter-weight fit, since it reuses existing action-value evaluation rather than adding new execution branching — but this needs a real design pass, not a default choice, given it changes how much computation CEL expressions are expected to carry versus the Rust action-execution layer.
Architecture Impact
No existing ADR documents playbook action/CEL capabilities as closed or enumerates a final set — this is additive new capability, not a reversal.
Acceptance Criteria
- Design decision made and documented (new
ActionKindvs. CEL aggregate function) with rationale - At minimum,
sumover a numeric field across a resolved collection is supported - Result is written to a target node's field via existing action-writing mechanism
- Aggregation correctly re-runs when any contributing item changes (not just once at collection-resolution time) — behavior under the existing trigger/event model needs explicit test coverage, since this is a derived value that must stay in sync with its inputs, the same correctness bar
has_childauto-complete (a related but distinct issue) holds itself to - Tests pass (
bun run test:all) - Code passes
bun run quality:fix
Technical Specifications
Reference Files
packages/core/src/playbook/actions.rs—for_eachexecution (~line 633 onward) — the collection-resolution precedent to build from or alongsidepackages/core/src/playbook/cel.rs—build_condition_context(~line 250), existing custom function registration (~lines 344-346) — where a CEL-level aggregate function would be added if that shape is chosenpackages/core/src/playbook/types.rs—ActionDefinition/ParsedAction(~lines 182, 341) — where a newActionKindwould be declared if that shape is chosen
Dependencies
None — this is a standalone engine capability, usable independent of any specific recipe.
Related Issues
- Add methodology recipe mechanism (TS source, generated CLI reference doc) with Linear-style as first recipe #2596 (Linear-style methodology recipe) — a cycle estimate-totals feature in that recipe would be a direct consumer of this capability once it exists, but is not required for Add methodology recipe mechanism (TS source, generated CLI reference doc) with Linear-style as first recipe #2596's core scope
Non-Goals
- Any specific recipe content (Cycle estimate totals, etc.) — this issue is the general engine capability only
- Aggregation functions beyond sum/count for this issue's initial scope (avg, min, max, etc. can follow as real needs surface)
Activity
mstomar125 commentedon Sep 17, 2026
Frontend baseline: 251 test files / 5150 tests passed. Starting implementation.