scope aware state views

This commit is contained in:
lda
2026-05-25 00:10:33 +07:00 Verified
parent ea1f746512
commit 2e252f6252
3 changed files with 103 additions and 3 deletions
+8 -3
View File
@@ -3,7 +3,11 @@ from __future__ import annotations
from typing import Any
from wf_core.run_state import ExecutionFrame, RunState
from wf_core.runtime.lineage import LineageStateView, lineage_writes_for_frame
from wf_core.runtime.lineage import (
LineageStateView,
lineage_writes_for_frame,
scope_state_for_frame,
)
def state_view_for_frame(run: RunState, frame: ExecutionFrame) -> dict[str, Any]:
@@ -13,8 +17,9 @@ def state_view_for_frame(run: RunState, frame: ExecutionFrame) -> dict[str, Any]
foreach barrier commits. Later nodes in the same item must read those
earlier writes, while sibling item frames must not see them.
"""
scope_state = scope_state_for_frame(run, frame)
writes = lineage_writes_for_frame(run, frame)
if not writes:
return run.state
return scope_state
return LineageStateView(run.state, writes).to_state_dict()
return LineageStateView(scope_state, writes).to_state_dict()