본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Workflow 히스토리 전파 (History propagation)

원문 보기 위키 갱신

부모 워크플로의 실행 히스토리를 자식 워크플로와 액티비티에 공유해 체인 오브 커스터디(chain-of-custody), 감사, AI 에이전트 컨텍스트에 활용하는 방법을 살펴봐요. 기본적으로 자식 워크플로나 액티비티는 스케줄될 때 함께 받은 입력만 볼 수 있습니다. 부모의 실행 히스토리 — 어떤 액티비티가 실행됐는지, 어떤 자식 워크플로를 만들었는지, 어떤 이벤트를 관찰했는지 — 는 보이지 않아요. 워크플로 히스토리 전파는 부모가 자신이 스케줄하는 워크플로와 자신의 히스토리를 공유하도록 선택(opt-in)할 수 있게 해줍니다. 이것은 다음과 같은 경우에 유용해요.

  • 체인 오브 커스터디와 감사 — 사기 검사, 컴플라이언스 게이트, 정산 단계가 호출자의 주장을 믿는 대신 업스트림에서 이미 무슨 일이 일어났는지 검증할 수 있어요.
  • 크로스 앱 워크플로 — 보통 다른 팀이 소유한 다운스트림 앱이 별도의 쿼리 없이도 업스트림 액티비티가 실행됐는지 확인할 수 있어요.
  • AI 에이전트와 장기 실행 오케스트레이션 — ContinueAsNew로 루프를 돌거나 하위 에이전트로 팬아웃하는 에이전트가 비싼 호출을 처음부터 다시 프롬프팅하지 않고도 컨텍스트(도구 호출, 모델 출력, 중간 결정)를 앞으로 전달할 수 있어요.

출처: Dapr 문서

본문

전파 범위 (Propagation scopes)

두 가지 범위를 사용할 수 있습니다. 기본값은 전파 없음이에요.

| Option helper | Scope value carried | What gets sent | When to use it | | workflow.PropagateLineage() | LINEAGE (HISTORY_PROPAGATION_SCOPE_LINEAGE) | Caller’s own events plus the full ancestor chain inherited from the caller’s parent | Full chain-of-custody, downstream wants to see everything that happened before, all the way to the root | | workflow.PropagateOwnHistory() | OWN_HISTORY (HISTORY_PROPAGATION_SCOPE_OWN_HISTORY) | Caller’s own events only, ancestral (parents) lineage is dropped | Trust boundary — the caller is willing to vouch for what it did but the receiver shouldn’t see further upstream | 헬퍼(PropagateLineage / PropagateOwnHistory)는 스케줄할 때 전달하는 것이고, 각 SDK마다 그에 상응하는 것이 있습니다(아래 예제 참조). 범위 값(LINEAGE / OWN_HISTORY)은 런타임 열거형 이름으로, 전파에 담겨 전달됩니다. PropagateOwnHistory는 신뢰 경계입니다. 이를 선택하면 런타임이 호출자가 받은 히스토리를 더 이상 전달하지 말라고 지시합니다. 수신자가 신뢰도가 낮은 앱, 제3자, 또는 다른 컴플라이언스 규칙 아래에서 동작할 때 올바른 선택이에요.

어떤 범위를 써야 할까요? (Which scope should I use?)

PropagateLineage가 가장 흔한 선택입니다. 대부분의 워크플로는 수신자가 업스트림에서 일어난 일의 전체 체인을 보길 원하거든요. 그게 위의 체인 오브 커스터디·감사·에이전트 컨텍스트 유스케이스를 가능하게 만드는 이유입니다. 결정은 체인에서 얼마나 아래까지 공유할 의향이 있는지에 관한 문제예요. PropagateOwnHistory는 신뢰 경계를 넘을 때만 사용하세요. 수신자가 신뢰도가 낮은 앱, 제3자, 또는 다른 컴플라이언스 규칙 아래서 동작하고, 자신의 단계에 대해 보증할 의향은 있지만 부모에게서 상속받은 모든 것을 전달하지는 않으려 할 때 말이죠. 그런 경우가 아니라면 lineage를 선호하세요.

페이로드 크기에 유의 (Mind the payload size)

전파된 히스토리는 스케줄된 호출의 페이로드 일부로 운반되고 수신자의 히스토리에 저장됩니다. PropagateLineage에서는 페이로드가 조상 체인의 깊이와 함께 커집니다. 깊은 워크플로 트리와 장기 실행 오케스트레이션은 Dapr의 기본 gRPC 메시지 한계(4 MB, 구성 가능)에 가까워질 수 있어요. PropagateOwnHistory는 상속된 조상 체인을 버려 페이로드를 더 작게 유지합니다.

설정하기 (Setting it up)

부모는 호출별 옵션으로 단일 자식 워크플로나 액티비티에 대해 전파를 활성화합니다. 같은 워크플로의 다른 호출에는 영향을 주지 않고, 기본값은 여전히 전파 없음입니다.

  • Python
  • .NET
  • Go
import dapr.ext.workflow as wf

@wfr.workflow(name='MerchantCheckout')
def merchant_checkout(ctx: wf.DaprWorkflowContext, order_json: str):

yield ctx.call_activity(validate_merchant, input=order_json)


result = yield ctx.call_child_workflow(
process_payment,
input=order_json,
propagation=wf.PropagationScope.LINEAGE,
)
return result
using Dapr.Workflow;

public sealed class MerchantCheckoutWorkflow : Workflow<Order, string>
{
public override async Task<string> RunAsync(WorkflowContext ctx, Order order)
{
// The ValidateMerchantActivity does NOT receive propagated history (default).
await ctx.CallActivityAsync<bool>(nameof(ValidateMerchantActivity), order);

// The ProcessPaymentWorkflow child workflow DOES receive parent's history (Lineage).
var childOptions = new ChildWorkflowTaskOptions()
.WithHistoryPropagation(HistoryPropagationScope.Lineage);
return await ctx.CallChildWorkflowAsync<string>(
nameof(ProcessPaymentWorkflow),
order,
options: childOptions);
}
}
import (
"github.com/dapr/durabletask-go/workflow"
)

func MerchantCheckout(ctx *workflow.WorkflowContext) (any, error) {
// Activity does NOT receive propagated history (default).
if err := ctx.CallActivity("ValidateMerchant").Await(nil); err != nil {
return nil, err
}

// Child workflow DOES receive parent's history (LINEAGE).
var result string
if err := ctx.CallChildWorkflow("ProcessPayment",
workflow.WithHistoryPropagation(workflow.PropagateLineage()),
).Await(&result); err != nil {
return nil, err
}
return result, nil
}

전파된 히스토리 접근하기 (Accessing propagated history)

자식 워크플로나 액티비티 안에서 GetPropagatedHistory()(Go / .NET) 또는 get_propagated_history()(Python)를 호출하세요. 호출자가 opt-in했다면 전파된 히스토리를 반환하고, 그렇지 않으면 None / nil을 반환합니다. 돌려받는 것은 호출자가 이 호출을 스케줄한 시점의 실행 스냅샷(point-in-time)입니다. 이미 실행된 단계들이지, 호출자가 그 후에 하는 일은 아니에요. 위 MerchantCheckout 부모에서 ValidateMerchant는 자식 워크플로가 스케줄되기 전에 완료되었으므로, 자식이 받는 전파된 히스토리에 나타납니다. 아래 예제는 위에 보인 부모 워크플로가 MerchantCheckout으로 등록되어 있고, 액티비티 ValidateMerchant와 자식 워크플로 ProcessPayment(Lineage로 호출)가 있다고 가정합니다.

  • Python
  • .NET
  • Go
import dapr.ext.workflow as wf

@wfr.workflow(name='FraudDetection')
def fraud_detection(ctx: wf.DaprWorkflowContext, order_json: str):
history = ctx.get_propagated_history()
if history is None:
return 'no upstream history'


if not ctx.is_replaying:
print(f'scope={history.scope}, workflows={[w.name for w in history.get_workflows()]}')

try:
merchant_wf = history.get_last_workflow_by_name('MerchantCheckout')
validation = merchant_wf.get_last_activity_by_name('ValidateMerchant')
except wf.PropagationNotFoundError as exc:
return f'missing required upstream step: {exc}'

if not validation.completed:
return 'merchant validation did not complete, rejecting'
return 'approved'
using Dapr.Workflow;

public sealed class FraudDetectionWorkflow : Workflow<Order, string>
{
public override Task<string> RunAsync(WorkflowContext ctx, Order order)
{
var history = ctx.GetPropagatedHistory();
if (history is null)
return Task.FromResult("no upstream history");

// Logs once instead of repeatedly during replays — not required, just keeps logging clean.
if (!ctx.IsReplaying)
Console.WriteLine($"received {history.Events.Count} ancestor workflow event(s)");

// Verify MerchantCheckout is present in the ancestor chain.
if (!history.TryGetLastWorkflowEventByName(nameof(MerchantCheckoutWorkflow), out _))
return Task.FromResult("MerchantCheckout missing from propagated history, rejecting");

return Task.FromResult("approved");
}
}
import (
"fmt"

"github.com/dapr/durabletask-go/workflow"
)

func FraudDetection(ctx *workflow.WorkflowContext) (any, error) {
propagatedHistory := ctx.GetPropagatedHistory()
if propagatedHistory == nil {
return "no upstream history", nil
}

// The history exposes both raw events and per-app/per-instance chunks.
fmt.Printf("scope: %s, %d events from apps %v\n",
propagatedHistory.Scope(), len(propagatedHistory.Events()), propagatedHistory.GetAppIDs())

// Drill into a specific upstream workflow's activities.
merchantWf, err := propagatedHistory.GetLastWorkflowByName("MerchantCheckout")
if err != nil {
return nil, fmt.Errorf("expected MerchantCheckout in propagated history: %w", err)
}
validation, err := merchantWf.GetLastActivityByName("ValidateMerchant")
if err != nil {
return nil, fmt.Errorf("expected ValidateMerchant in propagated history: %w", err)
}
if !validation.Completed {
return "merchant validation didn't complete, rejecting", nil
}
return "approved", nil
}

모든 SDK가 동일한 기본 모델을 줍니다. 실행 순서대로 정렬된 조상 워크플로 체인으로, 각 워크플로는 자신의 ID(앱 ID, 인스턴스 ID, 이름)와 함께 실행한 액티비티·자식 워크플로를 담고 있어요. 반환된 객체에서 다음을 할 수 있습니다.

  • 조상 체인 나열 — 실행 순서대로 조상 워크플로당 항목 하나씩.
  • 이름으로 조상 워크플로 조회 — 가장 최근 일치 또는 모든 일치.
  • 항목 안에서 이름으로 액티비티나 자식 워크플로 조회 — 같은 패턴으로.
  • 체인에 기여한 앱 확인 (중복 제거).
  • 부모가 선택한 전파 범위(LINEAGE 또는 OWN_HISTORY) 읽기 — SDK가 수신 측에 노출하는 경우.

각 언어의 정확한 메서드 시그니처는 Related links 아래 연결된 실행 가능한 예제를 참고하세요.

멀티 앱 워크플로에서의 히스토리 전파 (History propagation in multi-app workflows)

App A의 부모 워크플로가 멀티 앱 워크플로 호출로 App B의 자식 워크플로를 호출하면, 전파된 컨텍스트는 두 사이드카 사이의 네트워크를 가로질러 이동합니다. 그 홉을 보호하는 두 가지가 있어요. 컨텍스트가 지나는 채널과 컨텍스트 자체에 대한 서명입니다.

전송 보안 (mTLS) (Transport security (mTLS))

전파된 컨텍스트는 사이드카 간 gRPC 채널을 타므로, 그 채널을 보호하는 모든 것을 상속합니다. Dapr이 mTLS로 실행될 때 — Helm과 dapr init -k의 기본값 — 그 트래픽은 암호화되고 두 사이드카는 상호 인증되므로, App A와 App B 사이에 있는 어떤 것도 컨텍스트를 읽거나 주입할 수 없어요. mTLS는 아래의 서명의 전제 조건이기도 합니다. mTLS가 제공하는 SPIFFE X.509 ID가 프로듀서가 서명하는 키이기 때문입니다.

워크플로 히스토리 서명 (Workflow history signing)

mTLS는 전송 중 컨텍스트를 보호하지만, 도착한 내용이 진짜인지에 대해서는 아무 말도 하지 않습니다. 서명이 그 간극을 메웁니다. WorkflowHistorySigning Configuration 기능이 활성화되면, 프로듀싱 앱이 각 전파 청크를 SPIFFE ID로 서명하고, 수신자는 프로듀서를 떠난 뒤 그 청크가 변조되지 않았는지 암호학적으로 검증할 수 있어요. 서명이 어떻게 체인화·저장·로드 시 검증되는지에 대한 전체 메커니즘은 Workflow history signing을 참고하세요. WorkflowHistorySigning이 활성화되지 않으면 daprd는 전달마다 경고를 기록합니다. propagating unsigned workflow history to child workflow '...' (signing is not configured; context cannot be cryptographically verified by the receiver)

서명되지 않은 청크는 신뢰하지 말 것 (Treat unsigned chunks as untrusted)

서명이 없으면 전파된 컨텍스트는 기능하지만 암호학적으로 검증 가능하지 않습니다. 고가치 결정(결제, 승인)에 서명되지 않은 전파 히스토리를 권위 있는 것으로 취급하지 마세요. 체인 오브 커스터디에 의존하는 프로덕션 배포에는 WorkflowHistorySigning을 활성화하세요.

ContinueAsNew와 재실행 (ContinueAsNew and rerun)

전파된 히스토리는 ContinueAsNew와 Rerun 워크플로 연산 모두에서 올바르게 유지됩니다.

  • 전파된 히스토리를 받고 ContinueAsNew를 호출하는 워크플로는 같은 수신 컨텍스트를 다음 세대에 전달합니다.
  • 워크플로를 재실행하면 원래 스케줄되었던 것과 같은 전파 범위로 액티비티/자식 워크플로 호출을 다시 발행합니다. LINEAGE는 LINEAGE로, OWN_HISTORY는 OWN_HISTORY로 유지돼요.

이렇게 하면 장기 실행 에이전트와 크래시 복구 시나리오가 기대한 대로 동작합니다. 수신 세대/재실행은 원래 실행과 같은 히스토리를 봅니다.

다음 단계 (Next steps)

이전 워크플로나 액티비티 단계의 유효성을 암호학적으로 증명하는 워크플로 히스토리 서명 적용 방법을 알아보세요. Workflow patterns >>

  • Workflow history signing
  • Workflow 개요
  • Workflow 기능과 개념
  • Workflow 아키텍처
  • How to author a workflow
  • Workflow API 레퍼런스
  • 각 SDK의 예제 코드 확인: Python 예제
  • .NET 퀵스타트
  • Go 예제

더 알아보기 (Learn more)