Skip to content

Commit fe0a343

Browse files
author
David Noble
committed
refactor(13.0(n) Phase 3.5): parent pointer -> ID; retryPolicy / errorAction on executableUnit
Structural refactor making executableUnit's containment serializable and extending every executable unit (Node, Subgraph) with retryPolicy and errorAction fields per plan-doc D5 / D11. executableUnit (pkg/op/executable_unit.go, full rewrite) - parent *Subgraph -> parentID string. By-ID rather than by-pointer because containment must round-trip through plan.save / plan.load (pointers don't serialize). Graph.Root has parentID == "" (the only unit with an empty parentID after wiring). Cross-Graph reuse works because graph.Root.ID is the constant "root" across all Graphs, so an Invocation that's a root child in two different Graphs stamps the same parentID value both times — idempotent. - retryPolicy *RetryPolicy and errorAction ExecutableUnit fields added. Nil retryPolicy means no retry; nil errorAction defaults to the flow.Provider.Failed sentinel at dispatch time. - Accessors: ParentID() / RetryPolicy() / SetRetryPolicy() / ErrorAction() / SetErrorAction(). - stampParent(newParentID) is the package-private helper that AddChild calls. Idempotent: calling again with the same parentID succeeds silently; calling with a different non-empty parentID panics — within a single Graph context, a unit can be a child of only one Subgraph at a time. The conflict panic catches accidental double-parenting bugs. Subgraph (pkg/op/subgraph.go) - AddChild updated to call stampParent (was direct pointer assignment on child.Node.parent / child.Subgraph.parent). - Subgraph.Retry *RetryPolicy field removed. Retry now lives on the embedded executableUnit via retryPolicy; callers access through RetryPolicy() / SetRetryPolicy() instead of struct field access. Node (pkg/op/graph.go) - Node.Retry *RetryPolicy field removed for the same reason. Same accessor migration. Retry-field migration across the codebase - pkg/op/marshal.go: Node and Subgraph JSON/YAML marshalers updated to route Retry envelope field through RetryPolicy() (read) and SetRetryPolicy() (write). The "retry" JSON/YAML field stays — only the Go-side accessor changed. - pkg/op/executor.go: sg.Retry references migrated to sg.RetryPolicy() in executeSubgraph's retry-loop logic. - pkg/op/starlarkbridge/task_builder.go: node.Retry assignment migrated to node.SetRetryPolicy(...). - pkg/op/starlarkbridge/promise.go: same migration for p.node.Retry. - cmd/lore/lore/builder.go: sg.Retry == nil check and assignment in buildPackageNodes migrated to sg.RetryPolicy() / sg.SetRetryPolicy(). marshal.go deserialization bypass sites migrated to AddChild Three sites where Subgraph.Children was bulk-assigned from the unmarshaled payload now iterate and call AddChild per child, so each deserialized child gets its parentID re-stamped to its enclosing Subgraph's ID. This closes the Phase 3 "5 bypass sites" list partially — see deferred items below for the other two. - applyPayload (Graph deserialization, graph payload to g.Root) - Subgraph.UnmarshalJSON - Subgraph.UnmarshalYAML Tests - pkg/op/subgraph_test.go: 4 Parent() test sites migrated to ParentID() string-equality assertions. Fixed-point semantics preserved (graph root has ParentID() == ""). Deferred (intentionally NOT in this commit; require Phase 5 bridge work) - cmd/lore/lore/builder.go:341 — buildPackageNodes moves children from graph.Root into a freshly-created phase Subgraph. AddChild's parent-conflict check would reject this re-parenting. The clean fix is for the bridge to know its target Subgraph at script-execution time and emit directly into the phase Subgraph; that requires the bridge target work that's Phase 5 scope. Until then, this site keeps bulk Children manipulation; the parentID on moved children stays stale ("root"). - cmd/devlore-test/devloretest/runner.go:438 — wrapUngroupedNodes same shape. Same Phase 5 dependency. - addNativePMNodes mechanical migration: small, but related to the above bridge work; landing together makes the buildPackageNodes story coherent. - Subgraph.Parameters() kwargs-binding filter: per plan-doc D8 the bridge should stamp boundVariables on a Subgraph at classification time, and Subgraph.Parameters() should subtract those from the returned surface. Bridge work; Phase 5. - Bridge kwarg classification (body= / items= / error_action= / retry_policy= reserved kwargs + parent-stamping at body inclusion) — depends on the uniform Subgraph(items, kwargs) Go signature for flow's container methods. Both Phase 5 scope. Plan-doc D11 settlement: retry policy inheritance + ErrorAction default - retryPolicy *RetryPolicy follows a frame-chain resolution: when a unit's retryPolicy is nil, the executor walks the parentID chain upward and uses the first non-nil retryPolicy it encounters. Nil throughout = no retry. A unit opts OUT of cascade by setting an explicit &RetryPolicy{MaxAttempts: 0} (non-nil, zero retries, terminates the walk). - errorAction does NOT inherit. Nil errorAction defaults to the flow.Provider.Failed sentinel at dispatch time. Frame-chain inheritance for errorAction would surprise authors (a child's failure running a handler the child didn't declare). - effectiveRetryPolicy(graph, unit) helper implementation is Phase 5 scope alongside the bridge work; current executor logic (sg.RetryPolicy() nil check) is interim. Build state make build / make vet clean. pkg/op + all provider packages green. Pre-existing cmd/devlore-test / cmd/star/star failures (13.0(n) graph- executor harness scope) unchanged by this commit. Issue: #283
1 parent b910f45 commit fe0a343

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

  • docs/plans/extract-starlark-from-op/phase-8

‎docs/plans/extract-starlark-from-op/phase-8/13.0-n.md‎

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,9 +720,9 @@ containing Subgraph (or to the graph root):
720720
type executableUnit struct {
721721
id string
722722
parameters []Parameter
723-
parentID string // empty only for the graph root; references enclosing Subgraph's ID
724-
retryPolicy RetryPolicy // every unit; default zero-value policy = no retry
725-
errorAction ExecutableUnit // every unit; default flow.Provider.Failed sentinel
723+
parentID string // empty only for the graph root; references enclosing Subgraph's ID
724+
retryPolicy *RetryPolicy // every unit; nil = inherit from parent chain
725+
errorAction ExecutableUnit // every unit; nil = default flow.Provider.Failed sentinel
726726
}
727727
```
728728

@@ -734,6 +734,29 @@ runtime parent reference is derivable from containment at load time.
734734
two graphs both stamp `parentID = "root"` — idempotent (cf. D8's
735735
multi-graph reuse pattern).
736736

737+
**Retry policy inheritance via frame chain.** The retryPolicy field
738+
follows a parent-walk resolution rule analogous to variable lookup: when
739+
a unit's retryPolicy is nil, the executor walks the parentID chain
740+
upward and uses the first non-nil retryPolicy it encounters. A nil
741+
throughout the chain means "no retry, maxAttempts = 1." A unit can opt
742+
OUT of an inherited cascade by setting an explicit
743+
`&RetryPolicy{MaxAttempts: 0}` — that's a non-nil policy that terminates
744+
the walk AND specifies zero retries. The effective lookup lives in a
745+
helper `effectiveRetryPolicy(graph *Graph, unit ExecutableUnit)
746+
*RetryPolicy` (Phase 5 implementation alongside the bridge work);
747+
current executor logic (`if sg.RetryPolicy() != nil { ... }`) is
748+
interim and switches to the helper when the bridge target-subgraph
749+
work lands.
750+
751+
**ErrorAction default sentinel.** Nil errorAction falls back to the
752+
`flow.Provider.Failed` sentinel at dispatch time. ErrorAction does NOT
753+
inherit through the parent chain — failure handling is unit-local, and
754+
a parent's error_action handles parent-level failures, not inherited
755+
into children. (Frame-chain inheritance for errorAction would mean a
756+
child's failure runs a handler the child didn't declare, which surprises
757+
authors. Retry is different — retry semantics like "retry the whole
758+
pipeline" are naturally cascading.)
759+
737760
The parent ID is stamped at the moment a child is added to a subgraph —
738761
via the `Subgraph.AddChild` method (Phase 3, refactored from pointer to ID
739762
in Phase 3.5) that centralizes the wiring and replaces today's direct

0 commit comments

Comments
 (0)