Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 52 additions & 4 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- knowledge
last_checked: "2026-11-12T01:14:36Z"
last_checked: "2026-11-16T03:43:28Z"
-->
# Architecture

Expand Down Expand Up @@ -130,9 +130,57 @@ commits, detached values, and raw chunk delivery, and the
[frame failure tests](tests/engine/test_frame_failures.py) for pause/restore and
consumer exceptions.

Baselines and commits contain full variable values.
`ResponseStreamFilter` suppresses those events from its output after the engine has constructed and copied them; this compatibility guard does not add child response assembly.
Response buffers and presentation state remain in the filter, separate from runtime snapshots.
Baselines and commits contain full variable values. `ResponseStreamFilter`
consumes those events without forwarding them to its output. The engine
still constructs the events and copies their values.

## Response sessions

[ResponseStreamFilter](src/graphon/engine/filter/builtin/response_stream/filter.py)
owns independent root and child [frame sessions](src/graphon/engine/filter/builtin/response_stream/frame_session.py).
Root templates use the existing Python node interfaces. Child Answer and End
templates come from [retained definitions](src/graphon/engine/filter/builtin/response_stream/frame_graph.py),
without constructing nodes or calling factories. Frame starts activate initially
eligible templates; taken and skipped edges control the remaining paths. A reserved
execution ID alone does not make a reply reachable. Custom frames without enough
declarative context get no response session; ordinary node and completion events
still pass through.

Keep `emit_frame_events=True` when using a context from `from_engine()`: the
filter waits for the root baseline before resolving values. Each observed frame keeps a detached value pool and applies
committed replacements in publication order, including when events are consumed
after engine frames have been removed. Result and variable-request events do not
apply values again. Direct contexts without `run_id` retain the legacy manual
event-stream behavior until a frame baseline is supplied.

[Template assembly](src/graphon/engine/filter/builtin/response_stream/template_stream.py)
feeds the filter output for both scopes. Child sources are keyed by execution,
attempt, and selector within their frame; each response and template occurrence
has its own cursor. An occurrence that has started reading a source remains on
that source through retries and overwrites. Retries replace undisplayed attempts;
committed replacements supply later occurrences. Successful and handled-failure
results close unfinished child sources without replaying their final values.
Child Answer chunks use the reserved Answer ID and `[answer_id, "answer"]`, with
one final marker after the complete template, including empty replies. Source
final markers close only their source. Ordinary Answer `answer` and `files`
outputs and host-bound file formatting remain unchanged.

Failed or aborted frames close displayed child Answers and discard their remaining
templates. Graph termination also settles frames before `flush()` is needed.
Completed frames release captured values and source buffers. Root chunks retain
their existing event shapes and shared source cursors. Filter persistence supports
only root response state: v1 migration discards child response state, and v2 stores
root state directly. Sessions started from an initial frame baseline record observed
skipped edges in v2 snapshots, so resumed templates do not consult future live
node states. Snapshots without this optional metadata retain the paired graph's
skip lookup.
After a child frame containing an Answer or End starts, `dumps()` and `loads()`
reject that filter instance's state, including after the frame finishes. Resuming
such a child frame is also rejected. Child pause/resume support and ordering
across parallel or nested response groups remain follow-up stages of
[#356](https://github.com/langgenius/graphon/issues/356).
Current sequential Loop/Iteration behavior, source policies, and these boundaries
are exercised by the [container response tests](tests/engine/test_container_response_streaming.py).

## State and execution invariants

Expand Down
4 changes: 2 additions & 2 deletions docs/development.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- knowledge
last_checked: "2026-11-12T01:14:36Z"
last_checked: "2026-11-16T03:43:28Z"
-->
# Development navigation

Expand Down Expand Up @@ -28,7 +28,7 @@ Follow the [variable and container contracts](../ARCHITECTURE.md#state-and-execu
| Import Dify DSL or wire node dependencies | [importer](../src/graphon/dsl/importer.py), [node factory](../src/graphon/dsl/node_factory.py) | [DSL tests](../tests/dsl/), especially importer, node factory, and app bootstrap |
| Change a built-in node | [nodes](../src/graphon/nodes/), [base node](../src/graphon/nodes/base/node.py) | Matching [node tests](../tests/nodes/); [workflow events](../tests/workflows/test_full_engine_events.py) for graph-visible changes |
| Change dispatch, scheduling, or containers | [engine](../src/graphon/engine/), [container effects](../src/graphon/nodes/container_effects.py) | [engine tests](../tests/engine/), [container values](../tests/nodes/test_container_effects.py), [container dispatch](../tests/nodes/test_container_dispatch.py), [workflow events](../tests/workflows/test_full_engine_events.py) |
| Change event payloads or response streaming | [raw frame observations](../ARCHITECTURE.md#raw-frame-observations), [node events](../src/graphon/node_events/), [engine events](../src/graphon/engine_events/), [filters](../src/graphon/engine/filter/) | [frame observation tests](../tests/engine/test_frame_observations.py), [frame failure tests](../tests/engine/test_frame_failures.py), [node event tests](../tests/node_events/), [engine event tests](../tests/engine_events/), [response filter tests](../tests/engine/test_response_stream_filter.py) |
| Change event payloads or response streaming | [raw frame observations](../ARCHITECTURE.md#raw-frame-observations), [response sessions](../ARCHITECTURE.md#response-sessions), [node events](../src/graphon/node_events/), [engine events](../src/graphon/engine_events/), [filters](../src/graphon/engine/filter/) | [frame observation tests](../tests/engine/test_frame_observations.py), [frame failure tests](../tests/engine/test_frame_failures.py), [node event tests](../tests/node_events/), [engine event tests](../tests/engine_events/), [response filter tests](../tests/engine/test_response_stream_filter.py), [container response tests](../tests/engine/test_container_response_streaming.py) |
| Change variables or secrets | [variable pool](../src/graphon/runtime/variable_pool.py), [segment models](../src/graphon/variables/segments.py), [variable models](../src/graphon/variables/variables.py), [conversion](../src/graphon/variables/factory.py), [variable assignment](../src/graphon/nodes/variable_assigner/) | [variable pool tests](../tests/runtime/test_variable_pool.py), [Iteration variable ownership](../tests/engine/test_iteration_variable_scopes.py), [variable tests](../tests/variables/), [assignment tests](../tests/nodes/variable_assigner/), [HTTP secret masking](../tests/http/test_executor_secret_masking.py) |
| Change persistence or resume | [runtime state](../src/graphon/runtime/runtime_state/), [container state](../src/graphon/runtime/container_state.py), [nested file snapshots](../src/graphon/variables/file_snapshot.py) | [runtime tests](../tests/runtime/), [file snapshots](../tests/variables/test_file_snapshots.py), [engine serialization](../tests/engine/test_runtime_state_serialization.py), [frame failure restoration](../tests/engine/test_frame_failures.py), [version isolation](../tests/test_snapshot_version_isolation.py) |
| Change model invocation | [graph-facing LLM protocol](../src/graphon/nodes/llm/runtime_protocols.py), [Slim adapter](../src/graphon/dsl/slim/llm.py), [model runtime](../src/graphon/model_runtime/) | [LLM node tests](../tests/nodes/llm/), [Slim tests](../tests/dsl/test_slim_llm.py), [model dispatch](../tests/model_runtime/test_model_dispatch.py) |
Expand Down
12 changes: 6 additions & 6 deletions docs/technical-debt.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- knowledge
last_checked: "2026-11-12T01:14:36Z"
last_checked: "2026-11-16T06:25:48Z"
-->
# Technical debt

Expand Down Expand Up @@ -86,15 +86,15 @@ successful node order. Keep the example small enough to serve as a reproduction.
The [benchmark](../benchmarks/test_engine_performance.py) does not isolate the
response-filter initialization cost, leaving a gap in performance feedback.

Continue [PR #271](https://github.com/langgenius/graphon/pull/271) for the known
response-filter initialization path and
[Response-filter regressions](../tests/engine/test_response_stream_filter_performance.py)
cover unreachable-path pruning and per-response blocking-edge caching. Continue
[PR #266](https://github.com/langgenius/graphon/pull/266) for benchmark instructions.
Prefer deterministic complexity checks for that path and identify which phase a
measurement covers. Add timing workloads only for a specific performance question.

**Completion:** a runnable filter regression preserves output correctness, the
command is discoverable, and results distinguish construction, initialization,
and execution. Preserve existing benchmarks and
**Completion:** performance commands are discoverable, and results distinguish
construction, initialization, and execution. Preserve output correctness,
existing benchmarks, and
[response-filter tests](../tests/engine/test_response_stream_filter.py).

## TD-10 — Decision records
Expand Down
Loading
Loading