Skip to content

Commit 69a78d6

Browse files
refactor(workflow): drop propagate_lineage/propagate_own_history factories
Per review feedback, Go-style factory helpers are not idiomatic Python: they obscure the actual enum value at the call site and confuse static type checkers (return annotation only shows PropagationScope, not the specific member). Use PropagationScope.LINEAGE / PropagationScope.OWN_HISTORY directly instead. Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
1 parent e01361c commit 69a78d6

5 files changed

Lines changed: 13 additions & 43 deletions

File tree

examples/workflow/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,9 +544,9 @@ history to a child workflow and to an activity, and how the receivers query
544544
that history through `ctx.get_propagated_history()`.
545545

546546
It shows:
547-
- `propagation=propagate_own_history()` on a child workflow call —
547+
- `propagation=PropagationScope.OWN_HISTORY` on a child workflow call —
548548
forwards the caller's events only.
549-
- `propagation=propagate_lineage()` on an activity call — forwards the
549+
- `propagation=PropagationScope.LINEAGE` on an activity call — forwards the
550550
caller's events *plus* anything the caller itself received from its parent.
551551
- `PropagatedHistory.get_last_workflow_by_name(...)` and
552552
`WorkflowResult.get_last_activity_by_name(...)` on the receiving side.

examples/workflow/history_propagation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"""History propagation example.
1414
1515
The parent workflow runs a couple of activities, then calls a child workflow
16-
with ``propagation=propagate_own_history()`` and an activity with
17-
``propagation=propagate_lineage()``. The child workflow and the
16+
with ``propagation=PropagationScope.OWN_HISTORY`` and an activity with
17+
``propagation=PropagationScope.LINEAGE``. The child workflow and the
1818
downstream activity read the parent's recorded history via
1919
``ctx.get_propagated_history()`` and inspect specific events by name.
2020
@@ -106,14 +106,14 @@ def merchant_checkout(ctx: wf.DaprWorkflowContext, merchant_id: str):
106106
child_result = yield ctx.call_child_workflow(
107107
process_payment,
108108
input=None,
109-
propagation=wf.propagate_own_history(),
109+
propagation=wf.PropagationScope.OWN_HISTORY,
110110
)
111111
print(f'*** child workflow result: {child_result}', flush=True)
112112

113113
audit = yield ctx.call_activity(
114114
log_summary,
115115
input=None,
116-
propagation=wf.propagate_lineage(),
116+
propagation=wf.PropagationScope.LINEAGE,
117117
)
118118
print(f'*** audit activity result: {audit}', flush=True)
119119
return {'child': child_result, 'audit': audit}

ext/dapr-ext-workflow/dapr/ext/workflow/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
PropagationNotFoundError,
2626
PropagationScope,
2727
WorkflowResult,
28-
propagate_lineage,
29-
propagate_own_history,
3028
)
3129
from dapr.ext.workflow.retry_policy import RetryPolicy
3230
from dapr.ext.workflow.workflow_activity_context import WorkflowActivityContext
@@ -51,8 +49,6 @@
5149
'WorkflowResult',
5250
'ActivityResult',
5351
'ChildWorkflowResult',
54-
'propagate_lineage',
55-
'propagate_own_history',
5652
'DaprMCPClient',
5753
'MCPToolDef',
5854
]

ext/dapr-ext-workflow/dapr/ext/workflow/propagation.py

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,33 +34,20 @@ class PropagationScope(Enum):
3434
3535
Values map 1:1 to the protobuf ``HistoryPropagationScope`` enum; the
3636
plumbing layer reads ``.value`` when writing to proto fields.
37+
38+
* ``OWN_HISTORY`` — propagate the caller's events only; drop any ancestor
39+
chain. Use as a trust boundary, where downstream code should only see
40+
the immediate caller.
41+
* ``LINEAGE`` — propagate the caller's events plus any ancestor events it
42+
received. Use for chain-of-custody verification, where downstream code
43+
needs visibility into the full lineage of upstream workflows.
3744
"""
3845

3946
NONE = int(pb.HISTORY_PROPAGATION_SCOPE_NONE)
4047
OWN_HISTORY = int(pb.HISTORY_PROPAGATION_SCOPE_OWN_HISTORY)
4148
LINEAGE = int(pb.HISTORY_PROPAGATION_SCOPE_LINEAGE)
4249

4350

44-
def propagate_lineage() -> PropagationScope:
45-
"""Propagate the caller's own events plus any ancestor events it received.
46-
47-
Use this for chain-of-custody verification, where downstream code needs
48-
visibility into the full lineage of upstream workflows. Mirrors the
49-
go-sdk ``workflow.PropagateLineage()`` helper.
50-
"""
51-
return PropagationScope.LINEAGE
52-
53-
54-
def propagate_own_history() -> PropagationScope:
55-
"""Propagate the caller's events only; drop any ancestor chain.
56-
57-
Use this as a trust boundary, where downstream code should only see the
58-
immediate caller. Mirrors the go-sdk ``workflow.PropagateOwnHistory()``
59-
helper.
60-
"""
61-
return PropagationScope.OWN_HISTORY
62-
63-
6451
class PropagationNotFoundError(Exception):
6552
"""Raised when a query against propagated history finds no match."""
6653

ext/dapr-ext-workflow/tests/durabletask/test_propagation.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
PropagatedHistory,
2424
PropagationNotFoundError,
2525
PropagationScope,
26-
propagate_lineage,
27-
propagate_own_history,
2826
)
2927
from google.protobuf import wrappers_pb2
3028

@@ -372,14 +370,3 @@ def test_from_proto_handles_empty_chunks():
372370
assert ph.events == []
373371
assert ph.get_app_ids() == []
374372
assert ph.get_workflows() == []
375-
376-
377-
# --- Factory helpers (go-sdk parity) ----------------------------------------
378-
379-
380-
def test_propagate_lineage_helper_returns_lineage_scope():
381-
assert propagate_lineage() is PropagationScope.LINEAGE
382-
383-
384-
def test_propagate_own_history_helper_returns_own_history_scope():
385-
assert propagate_own_history() is PropagationScope.OWN_HISTORY

0 commit comments

Comments
 (0)