docs: publish structured runtime context
This commit is contained in:
+2
-2
@@ -117,8 +117,8 @@ docs as the active references:
|
||||
- [`superpowers/specs/2026-09-04-foreach-back-edge-design.md`](superpowers/specs/2026-09-04-foreach-back-edge-design.md):
|
||||
approved canonical foreach body-return and validation semantics.
|
||||
- [`superpowers/specs/2026-09-04-structured-runtime-context-design.md`](superpowers/specs/2026-09-04-structured-runtime-context-design.md):
|
||||
proposed same-scope nested foreach context, path, schema, and authoring-ref
|
||||
semantics.
|
||||
implemented same-scope nested foreach context, path, schema, and
|
||||
authoring-ref semantics.
|
||||
- [`superpowers/specs/2026-09-04-run-step-budget-design.md`](superpowers/specs/2026-09-04-run-step-budget-design.md):
|
||||
proposed persisted run-wide protection against unbounded graph execution.
|
||||
- [`superpowers/specs/2026-05-24-native-subgraphs-design.md`](superpowers/specs/2026-05-24-native-subgraphs-design.md):
|
||||
|
||||
@@ -48,7 +48,7 @@ and barrier foundations in this order.
|
||||
The implementation plan is ready and its feature branch is under review:
|
||||
|
||||
- [`structured runtime context design`](superpowers/specs/2026-09-04-structured-runtime-context-design.md)
|
||||
- [`structured runtime context implementation plan`](superpowers/plans/2026-09-04-structured-runtime-context.md)
|
||||
- [`structured runtime context implementation plan`](historical/superpowers/plans/2026-09-04-structured-runtime-context.md)
|
||||
|
||||
This slice gives runtime code, expressions, validation, and authoring references
|
||||
one model for run data and same-scope foreach activations. Subgraphs continue to
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
## Status
|
||||
|
||||
Approved for implementation on 2026-09-04. This document specifies structured
|
||||
Implemented on 2026-09-04. This document specifies structured
|
||||
foreach context inside one runtime scope. It complements the foreach back-edge
|
||||
design without expanding that implementation slice.
|
||||
|
||||
|
||||
@@ -248,6 +248,32 @@ See `examples/authoring_concurrent_foreach.py` for a runnable example covering:
|
||||
- the replace-conflict case when sibling item writes target a non-mergeable
|
||||
state path.
|
||||
|
||||
## Structured `foreach` context
|
||||
|
||||
Nested bodies read every active same-scope iteration through structured paths.
|
||||
Prefer declared input bindings via the foreach reference:
|
||||
|
||||
```python
|
||||
orders = graph.foreach(
|
||||
id="orders",
|
||||
over=state_path("orders"),
|
||||
as_="order",
|
||||
)
|
||||
charge = graph.use(
|
||||
charge_order,
|
||||
input=[input_from(orders.item, "order")],
|
||||
)
|
||||
graph.set_route(orders, "loop", charge)
|
||||
graph.set_route(charge, "ok", orders)
|
||||
```
|
||||
|
||||
The compiled binding is ordinary protocol data (`context.foreach.orders.item`).
|
||||
Normal capabilities receive foreach values through declared inputs. Advanced
|
||||
handlers may inspect `ctx.foreach["orders"].index` and stable runtime
|
||||
identities (`activation_id`, `frame_id`, `scope_id`, `lineage_id`). Child
|
||||
workflows do not inherit caller context and must receive input;
|
||||
`loop_item`, `loop_index`, and aliases are migration conveniences.
|
||||
|
||||
## Deprecated `route`
|
||||
|
||||
`route()` is a compatibility shim:
|
||||
|
||||
Reference in New Issue
Block a user