Skip to content

Add durable child-orchestration primitives with composable wait semantics#165

Open
Copilot wants to merge 3 commits into
mainfrom
copilot/add-durable-sub-orchestration
Open

Add durable child-orchestration primitives with composable wait semantics#165
Copilot wants to merge 3 commits into
mainfrom
copilot/add-durable-sub-orchestration

Conversation

Copilot AI commented May 23, 2026

Copy link
Copy Markdown

pg_durable had no first-class way to express “start a child orchestration and durably resume when it completes.” This change adds graph-composable child-wait primitives so parent workflows can model sub-orchestration flows without backend-session polling or hand-rolled loop/sleep polling.

  • New DSL primitives

    • Added df.await_instance(instance_id, timeout_seconds) as a durable future node that waits for another instance to reach a terminal state.
    • Added df.call_child(fut, label, options) as a convenience wrapper that starts a child via df.start(...) and then waits for it durably.
    • df.call_child currently supports:
      • timeout_seconds
      • database
      • on_failure = 'raise'
  • Runtime / orchestration support

    • Introduced a new AWAIT_INSTANCE node type.
    • Added orchestration handling for AWAIT_INSTANCE using durable timer-based polling plus an activity that reads child instance state.
    • Success resolves to a JSON envelope containing:
      • instance_id
      • status
      • result
    • Failed / cancelled children and wait timeouts surface as parent errors.
  • Compatibility / SQL surface

    • Updated df.ensure_durofut to recognize AWAIT_INSTANCE.
    • Updated df.grant_usage and the 0.2.0 -> 0.2.1 upgrade SQL so upgraded installs can grant and call the new functions immediately.
  • Docs

    • Added a short design doc: docs/child-orchestration-design.md
    • Updated the user guide and upgrade notes for the new API and current semantics.

Example

SELECT df.start(
    df.call_child(
        'SELECT json_build_object(''report_id'', 42, ''status'', ''ready'')',
        'generate-report',
        '{"timeout_seconds": 300}'
    ) |=> 'child'
    ~> 'INSERT INTO audit_log(payload) VALUES ($child::jsonb)',
    'parent-workflow'
);

This expands to a child df.start(...) plus a durable wait, and returns the child envelope to the parent graph.

Copilot AI and others added 2 commits May 23, 2026 12:41
Agent-Logs-Url: https://github.com/microsoft/pg_durable/sessions/67507bc7-fd80-4fa6-a05e-8fae4729c8d1

Co-authored-by: pinodeca <32303022+pinodeca@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/pg_durable/sessions/67507bc7-fd80-4fa6-a05e-8fae4729c8d1

Co-authored-by: pinodeca <32303022+pinodeca@users.noreply.github.com>
Copilot AI changed the title [WIP] Add missing durable sub-orchestration primitives Add durable child-orchestration primitives with composable wait semantics May 23, 2026
Copilot AI requested a review from pinodeca May 23, 2026 12:44
@pinodeca pinodeca marked this pull request as ready for review May 23, 2026 23:52
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.

Missing durable sub-orchestration primitive (df.call_child / df.await_instance)

2 participants