Skip to content

Supporting sinks and preservers #1102

Open

Description

@knoepfel

This issue serves as the parent issue for discussing the design of sinks and preservers.

Introduction

The notion of the preserver is prevalent in the Phlex conceptual design report (see the beginning of Chapter 3 and Section 3.8). Until now, the phlex implementation has supported only the concept of declared_outputs, which originates from Meld, Phlex's precursor. This issue describes an initial design for including preservers as part of the workflow graph, as depicted in Fig. 3.1 of the CDR and shown below for reference.

image

Reminder of providers, sources, and drivers

The graph above suggests an interesting interplay between providers, sources, and drivers. Sources are not explicitly depicted in that graph, but they serve the role of provider "factories", where providers can be implicitly created through a source whenever an explicit provider cannot satisfy the product-selection constraints imposed by a computational node.

In addition, any framework driver can access one or more configured sources, enabling the definition of the "event loop" from the sources themselves.

Where do preservers fit in?

Preservers have, until now, been unrepresented in the phlex implementation. Just like providers, each preserver is intended to preserve data products of one (and only one) data-product specification (e.g., the $\mathrm{preserve(GoodTracks)}$ node takes only the data products from the $[\mathrm{GoodTracks}_{i j k}]$ family). One could, in principle, achieve this by supporting explicit preservers (like we have explicit providers). However, having multiple explicit preservers that share the same output destination is likely cumbersom and, instead, argues for a preserver "factory", which we will term sink.

This provides the following complementarity:

  • Sources are factories for (implicit) providers
  • Sinks are factories for (implicit) preservers

Note

It is an open question whether explicit preservers would be useful. I am not certain they would be.

Initial support

For the first release of preservers, I suggest supporting one preserver per producer (transform, fold, unfold). Any data products created by the producer will be included in the phlex::experimental::product_store that is passed to the preserver.

Sink interface

  class sink {
  public:
    virtual ~sink() = default;
    virtual preserver_bundle create_preserver(/*<creator-specific information>*/) = 0;
  };

where the structure of preserver_bundle is not yet defined but will serve as the counterpart to the existing phlex::experimental::provider_bundle.

Preserver interface

A registered preserver function should have the signature

void fcn(phlex::experiment::product_store const&) { ... }

Each preserver node's preserver function will only receive product stores from its single upstream producer. This enables the setting of preserver state at preserver-construction time, and repeated invocations of the preserver function can treat that state as immutable.

Eventual support

Eventually, I believe it will be helpful for one preserver to be created per data-product specification. This does introduce some complications for marshaling data-products from the same data cell into a given FORM output container. These issues should be discussed.

Activity

  1. added
    enhancement
    on Nov 20, 2026
  2. added theissue type on Nov 20, 2026
  3. knoepfel commented on Nov 20, 2026

    @knoepfel
    MemberAuthor

    GPT-6.1 Astra evaluation of terminology

    [This evaluation was gently adjusted from analysis by GPT-6.1 Sol]

    Context

    The output side of framework_graph, currently represented by declared_output, is being redesigned. The terminology should distinguish output destinations from the executable operations that deliver data products to them, and distinguish framework-managed output delivery from observers' user-visible side effects.

    The proposed relationship is:

    • Providers can be created from sources.
    • Preservers can be created from sinks.

    This makes sink a counterpart to source, rather than a direct rename of the executable declared_output class.

    Proposed Vocabulary

    Term Responsibility
    Source An input-side abstraction capable of creating providers.
    Provider An executable operation that makes data products available to the framework for processing.
    Sink An output-side abstraction capable of creating preservers.
    Preserver An executable operation that makes data products, or information about them, available at its sink's destination for subsequent use.
    Observer An operation on selected inputs whose purpose is user-visible side effects, rather than framework-managed output delivery.

    Sources and sinks describe where data comes from and goes. Providers and preservers perform the corresponding work. This mirrors the existing separation between a source and its executable provider nodes.

    Providers make products available to the framework for processing; preservers make products, or information about them, available at output destinations for subsequent use. These names describe responsibilities rather than mechanisms such as reading and writing.

    Why Sink Fits

    Sink is established dataflow terminology for a destination that receives data without producing downstream data within the same graph. For this redesign, its more specific meaning is an output-boundary abstraction:

    A sink represents a destination to which framework data products are delivered through preservers, without producing downstream framework products.

    The term does not prescribe a storage backend. A sink could represent a file, an external service, an in-memory collection, or another output destination.

    It also reduces the ambiguity of output. Output products are values produced by algorithms; a sink is a destination receiving those products. The existing .output(...) and .output_product(...) interfaces use the same word for these different concepts.

    Distinction from Observers

    Graph topology alone does not distinguish a preserver from an observer: both can consume data without producing downstream framework products.

    The distinction is responsibility:

    • Observers perform computations on selected inputs for user-visible side effects.
    • Preservers participate in the framework's output-delivery contract, delivering products, or information about them, to destinations represented by sinks for subsequent use.

    Both an observer and a preserver might write a file. That implementation detail does not determine their category. What matters is whether the operation is a user algorithm with side effects or part of framework-managed output delivery.

    Relationship to the Current Implementation

    The current declared_output is an executable object, not merely output-declaration metadata. It owns a TBB node, accepts a callback of type void(product_store const&), and exposes a receiving port without a framework data-producing port.

    This makes preserver the closer conceptual successor to declared_output. Sink names the separate destination abstraction capable of creating those executable operations. The redesign therefore introduces a responsibility split, not just a vocabulary substitution.

    The current implementation also illustrates why an output destination should not be equated with receiving only final results. The output_products_test.cpp test expects three output callback invocations for one spill: one store from each of two providers and one from a transform. These are separate deliveries, not one consolidated completed-cell output.

    These observations describe the existing implementation, not requirements that the redesign must retain. The same test already notes the intended replacement of output nodes with preserver nodes.

    Contract Implications

    The names alone should not promise:

    • Aggregation into a complete cell or event.
    • Exactly one invocation per cell.
    • Completion ordering or end-of-job notification.
    • Durable storage.
    • Ownership transfer or exclusive access to products.

    Those properties belong in the redesigned interfaces and execution contract. A destination can be terminal along its own output branch while receiving intermediate products that remain available to other computations.

    Preserver intentionally implies preservation, but preservation does not require persistence. Products, or information about them, may be preserved in a file, an in-memory collection, a queue, or a buffer retained long enough for a downstream process to consume them. Handing products to another system can fulfill this responsibility when it maintains their availability for subsequent use; transmission alone is not the defining responsibility.

    The duration of availability and any delivery or retention guarantees belong in the execution contract, not the name.

    Recommendation

    Use source and sink for the input and output boundary abstractions, and provider and preserver for the executable operations they can create.

    Reserve observer for user-visible side effects outside the framework-managed output-delivery contract. Continue using output product and output port for the data and interfaces through which algorithms produce results.

    Under this model, sink is a suitable name for the new counterpart to source; preserver is the closer conceptual successor to declared_output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions