Skip to content

Add computed-date arithmetic to the playbook engine (action values, not just CEL conditions) #2640

Closed

Description

@malibio

Overview

The playbook engine's date support is read-only and condition-scoped: CEL registers exactly three date functions (days_since, days_until, today — packages/core/src/playbook/cel.rs, ~lines 344-346, 370-384), all of which compare an existing date string against "now" and return either a boolean-usable day count or today's own date. None of them compute a new date offset from an existing one (e.g. "14 days after this date"). This blocks any Play that needs to derive a future/past date and write it as a field value — a scheduled Cycle-creation Play computing a new Cycle's end_date from start_date + duration_days is the motivating, concrete case.

Problem Statement

This is a compound gap, not a single missing function, confirmed by direct inspection of both halves of the engine:

  1. No date-arithmetic function exists. CEL's registered function set has nothing like add_days(date, n) -> date. days_since/days_until only produce integers from a fixed "now" anchor; there is no way to add an offset to an arbitrary date and get a new date string back.
  2. Even if one existed, actions can't use it. packages/core/src/playbook/actions.rs has no CEL evaluation anywhere in its action-execution path — confirmed via search for cel/Cel/CEL in that file (zero hits). Action params values are resolved through a completely separate mechanism, resolve_bindings_in_string/resolve_bindings_in_value (~lines 504-580): a {path}-style path-substitution/interpolation scheme (e.g. {trigger.status}, {item.id}), not expression evaluation. CEL programs (cel.rs) are compiled and run only for trigger conditions, never for action values. So a date-arithmetic CEL function, on its own, would only be reachable from a condition (useful for "is this date more than N days old," which days_since already covers) — not from an action writing a computed date onto a node, which is the actual need.

No existing ADR or architecture doc names either gap as known/deferred — confirmed via search of ../nodespace-docs/decisions/ and ../nodespace-docs/architecture/.

Proposed Solution

Two coupled pieces of work, both required together for the motivating case to be expressible:

  1. A date-arithmetic function, e.g. add_days(date_string, n) -> date_string, registered alongside the existing three in cel.rs, following parse_date_and_compute_days's existing parsing precedent (accepts both full ISO 8601 datetime and bare YYYY-MM-DD).
  2. A way for an action value to be computed, not just path-substituted. The binding-interpolation mechanism in actions.rs needs a way to express "the value of this action param is the result of evaluating this CEL expression against the current binding context" — not a full CEL condition, but a computed value at action-execution time. Two shapes worth weighing during design:
    • Extend the existing {path} interpolation syntax to also accept a function-call form, e.g. {add_days(item.start_date, 14)}, evaluated through the same binding-resolution machinery rather than a separate CEL program.
    • Run a real (short) CEL program for any action param value that isn't a bare {path}, giving action values the same expression power conditions already have, with the binding context's resolved values exposed as CEL variables.

The second shape gives more power for less special-casing (reuses cel.rs machinery directly rather than teaching resolve_bindings_in_string new syntax) but changes the performance/complexity profile of every action-value resolution, not just date arithmetic specifically — this needs a real design decision, not a default pick, during implementation.

Architecture Impact

No existing ADR documents playbook action-value expression capabilities as closed or deliberately scoped to path-substitution-only — this is additive new capability, not a reversal.

Acceptance Criteria

  • Design decision made and documented (extend {path} interpolation vs. full CEL evaluation for action values) with rationale
  • add_days(date_string, n) (or equivalent) is available wherever the design lands it — at minimum, usable from an action computing a new date field value
  • A scheduled Play can compute end_date = start_date + N days and write it as a new node's field value end-to-end (integration test)
  • Existing {path} interpolation and CEL condition behavior is unaffected for every case that doesn't use the new capability
  • Tests pass (bun run test:all)
  • Code passes bun run quality:fix

Technical Specifications

Reference Files

  • packages/core/src/playbook/cel.rs — parse_date_and_compute_days (~line 387), existing function registration (~lines 344-346) — precedent and registration point for add_days
  • packages/core/src/playbook/actions.rs — resolve_bindings_in_string/resolve_bindings_in_value (~lines 504-580), BindingContext::resolve_binding (~line 274) — where computed-value support needs to be added, one way or another

Dependencies

None — this is a standalone engine capability, usable independent of any specific recipe.

Related Issues

Non-Goals

  • Any specific recipe content (Cycle schema, the Cycle-creation Play itself) — this issue is the general engine capability only
  • Date arithmetic beyond day-offset (month/year-aware calculations, business-day-aware calculations, etc.) — day-offset is sufficient for the motivating case; broader calendar arithmetic can follow as a real need surfaces

Activity

  1. mstomar125 commented on Sep 17, 2026

    @mstomar125
    Contributor

    Frontend: 5134 passed

  2. self-assigned this
    on Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions