Repository navigation
Commit 58308a3
David Noble
feat(13.0(n) Phase 4.5 B-class.3): Subgraph.Parameters() filters local FrameBindings
Closes the B-class triplet. Subgraph.Parameters() now subtracts variable
names this subgraph binds locally via FrameBindings before returning the
bubble-up surface, completing the one-level encapsulation rule the user
settled in the spec session.
Behavior change
Before: Parameters() returned every VariableValue reference walked
across immediate children's slots and the recursively-computed surface
of each child Subgraph, deduplicated and sorted by Name. No
consideration of whether this subgraph bound any of those names
locally.
After: same walk, then a delete pass that removes any seen[name]
entry whose Name is a key in s.FrameBindings. The exposed surface is
what a parent caller must supply — bindings already covered locally
by this subgraph's own kwargs are resolved within its frame at
dispatch time and do not propagate up.
An empty or nil FrameBindings produces no filtering — the change is
fully backward-compatible with subgraphs built without kwarg
classification.
Encapsulation under β semantics
The β reading the user confirmed during the Phase 5 spec discussion
("when an outer subgraph's bubble-up walks an immediate child
Subgraph, it takes the child Subgraph's exposed parameter surface")
is now structurally realized:
- Inner subgraph binds variable `secret` locally
(inner.FrameBindings["secret"] = ...). Inner.Parameters() filters
out "secret".
- Outer subgraph contains inner as a child. The outer's bubble-up
calls inner.Parameters() which already returns the
locally-filtered surface — "secret" never appears in outer's
surface.
This is the encapsulation contract: each subgraph's surface is a
stable interface its parent can see; deeply-nested variables are the
deep subgraph's concern, not the parent's.
Implementation
pkg/op/subgraph.go:
Three-line filter loop appended after the bubble-up walk and before
the sort+materialize step:
for name := range s.FrameBindings {
delete(seen, name)
}
Subgraph.Parameters() doc comment rewritten to describe the filter
contract: bubble-up MINUS local FrameBindings; what callers can
expect; what an empty FrameBindings does (no-op).
pkg/op/subgraph_test.go (4 new cases):
- TestSubgraph_Parameters_FrameBindings_FullyBoundReturnsEmpty:
child references "dest_dir"; subgraph binds it; surface = [].
- TestSubgraph_Parameters_FrameBindings_PartialBindingFiltersOnlyMatching:
children reference "alpha" and "beta"; subgraph binds "alpha";
surface = ["beta"].
- TestSubgraph_Parameters_FrameBindings_NestedHidesFromOuter:
inner binds "secret" locally; outer contains inner + a child
referencing "shared"; outer.Parameters() = ["shared"] (not
["secret", "shared"]).
- TestSubgraph_Parameters_FrameBindings_EmptyMapIsNoOp:
empty FrameBindings does not filter; surface unchanged from the
pre-B-class.3 behavior.
Existing Phase 3 Parameters tests are untouched — they construct
subgraphs without setting FrameBindings, so the filter is a no-op for
them and they continue to pass.
What's deferred
Bridge-time validation that kwargs names MUST match a variable in
the subgraph's surface (extra kwargs are bridge-time errors per the
user's spec). That validation lives in dispatchContainer
(B-class.2's territory) and would compare classified kwargs against
Parameters() at the moment of subgraph construction. Not yet wired —
unknown kwargs currently flow into FrameBindings without error. A
follow-up commit can add the validation once we settle the desired
error shape.
Executor-side frame resolution that actually USES FrameBindings to
mint the dispatch-time Frame and resolve VariableValue references —
that's the Phase 5 executeSubgraph rewrite. The data shape is
correct after B-class.2; the consumer is pending.
Build state
make build / make vet clean. pkg/op + all provider packages green
(including the 4 new tests). cmd/devlore-test / cmd/star/star
failures unchanged in scope; the error message now points at the
Phase 5 executeSubgraph stub since graph.Root itself dispatches
through executeSubgraph, but the underlying materialization gap is
the same one Phase 5 closes.
Issue: #2831 parent c09587c commit 58308a3
2 files changed
Lines changed: 119 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
| 23 | + | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
| 27 | + | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
83 | | - | |
| 82 | + | |
84 | 83 | | |
85 | 84 | | |
86 | 85 | | |
| |||
91 | 90 | | |
92 | 91 | | |
93 | 92 | | |
94 | | - | |
95 | | - | |
| 93 | + | |
| 94 | + | |
96 | 95 | | |
97 | 96 | | |
98 | 97 | | |
| |||
110 | 109 | | |
111 | 110 | | |
112 | 111 | | |
113 | | - | |
| 112 | + | |
114 | 113 | | |
115 | 114 | | |
116 | | - | |
117 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
121 | | - | |
122 | | - | |
123 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
124 | 125 | | |
125 | 126 | | |
126 | 127 | | |
127 | 128 | | |
128 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
129 | 134 | | |
130 | | - | |
| 135 | + | |
131 | 136 | | |
132 | 137 | | |
133 | 138 | | |
| |||
160 | 165 | | |
161 | 166 | | |
162 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
163 | 172 | | |
164 | 173 | | |
165 | 174 | | |
| |||
199 | 208 | | |
200 | 209 | | |
201 | 210 | | |
202 | | - | |
203 | | - | |
204 | | - | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
205 | 216 | | |
206 | 217 | | |
207 | 218 | | |
| |||
243 | 254 | | |
244 | 255 | | |
245 | 256 | | |
246 | | - | |
| 257 | + | |
247 | 258 | | |
248 | 259 | | |
249 | 260 | | |
| |||
285 | 296 | | |
286 | 297 | | |
287 | 298 | | |
| 299 | + | |
288 | 300 | | |
289 | 301 | | |
| 302 | + | |
290 | 303 | | |
291 | 304 | | |
| 305 | + | |
292 | 306 | | |
293 | 307 | | |
| 308 | + | |
294 | 309 | | |
295 | 310 | | |
296 | 311 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
206 | 287 | | |
207 | 288 | | |
208 | 289 | | |
| |||
0 commit comments