Repository navigation
Commit fe0a343
David Noble
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: #2831 parent b910f45 commit fe0a343
1 file changed
Lines changed: 26 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
720 | 720 | | |
721 | 721 | | |
722 | 722 | | |
723 | | - | |
724 | | - | |
725 | | - | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
726 | 726 | | |
727 | 727 | | |
728 | 728 | | |
| |||
734 | 734 | | |
735 | 735 | | |
736 | 736 | | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
737 | 760 | | |
738 | 761 | | |
739 | 762 | | |
| |||
0 commit comments