Repository navigation
fix(response-stream): avoid exponential path enumeration - #400
Merged
QuantumGhost merged 10 commits intoNov 18, 2026
Merged
QuantumGhost merged 10 commits into
QuantumGhost merged 10 commits into
Conversation
Cover filter-consumed traversal events when live engine state is ahead. Preserve partially consumed v1/v2 paths, buffered chunks, template and stream positions, execution IDs, and waiting-response order on restore. Assisted-by: Codex:gpt-6.1-sol
Track per-response reachability through nonblocking edges and consumed root traversal events instead of enumerating complete paths. Write v3 checkpoints with consumed edge IDs, retaining residual conditions when upgrading v1/v2 snapshots. Preserve session order and stream progress. Refs: ENG-1501 Assisted-by: Codex:gpt-6.1-sol
Merge current upstream response sessions while retaining independent incremental gating and versioned legacy checkpoint compatibility. Preserve first skipped/taken decisions, index child adjacency, and replace obsolete path-list assertions with public activation oracle checks. Refs: langgenius#398 Assisted-by: Codex:gpt-6.1-sol
QuantumGhost
marked this pull request as draft
November 16, 2026 08:30
Bound diamond-chain initialization at 6, 12 and 24 stages with traversal budgets, growth ratios, retained-state and checkpoint byte limits. Compare gating against old path conditions with Hypothesis independently of resource checks, and assert ordered replies and distinct frame targets. Refs: langgenius#398 Assisted-by: Codex:gpt-6.1-sol
Keep native reachability and imported legacy paths in exclusive runtime states, and reject mixed v3 input before binding it to a graph. Own first taken/skipped decisions once per frame, with response caches reading the map. Keep observed skips separate and decode existing v3 intersections as first-skip wins without changing the wire fields. Protect partially consumed native checkpoints and both loading orders; verify that dropping serialized taken edges fails the release assertions. Refs: langgenius#398 Assisted-by: Codex:gpt-6.1-sol
Use nominal NodeID and EdgeID types for response gating and v3 snapshots, converting graph/event and legacy inputs at their existing boundaries. Document first-decision lists, observed skips, and residual AND/OR paths. Keep serialized IDs as strings and retain the existing v3 JSON schema. Refs: langgenius#398 Assisted-by: Codex:gpt-6.1-sol
Member
Author
|
I have run the differential tests with ~10k iterations each on my machine. I'm pretty sure that the claimed property holds. |
Resume paired runtime/filter checkpoints captured by the c3870df and 069cd55 writers, with current-writer controls. Cover two HITL pause points, recheckpointing after migration, and host PauseCommand resumption. Assert meaningful execution identity and output behavior without treating synthetic root chunk UUID continuity as a restoration contract. Add reproducible historical fixture capture and test navigation. Refs: langgenius#398 Assisted-by: Codex:gpt-6.1-sol
Merge upstream main reply ordering while retaining per-response incremental gates, frame-owned first edge decisions, v3 snapshot compatibility and nominal node/edge IDs. Keep the interleaved-frame regression aligned with ordered presentation: opening B cannot open A, and B waits until frame A finishes. Validation: 1402 tests passed; static checks passed. Historical filter v1/v2 pause checkpoints continue to restore with the current v3 writer. Refs: langgenius#398, langgenius#401 Assisted-by: Codex:gpt-6.1-sol
41tair
approved these changes
Nov 18, 2026
This was referenced Nov 18, 2026
3 tasks done
laipz8200
added a commit
that referenced
this pull request
Nov 19, 2026
Merge main at eb75e38 into the pause/resume branch without rewriting the existing PR commits. Preserve first consumed edge decisions and legacy residual paths in v4 frame snapshots while retaining v1/v2/v3 readers and child reply progress. Reject mixed gating state before replacing saved progress and keep current snapshots independent of legacy codecs. Reconcile retained-state accounting with the caller-owned filter context and update the affected compatibility and ownership documentation. Refs #356, #400, #412.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AI disclosure: This PR was primarily drafted with Codex using gpt-6.1-sol. Final review and responsibility remain with the human author.
Important
!Related Issue
Closes #398.
Builds on #271, #374 and #401. Related downstream tracking: langgenius/dify#41851.
Summary
A 43-node workflow can contain
2^41structural paths when each conditional's two handles converge on the next node. Response initialization materialized every complete path before the first graph-start event. Reverse pruning from #271 cannot help when all paths reach the response.Approach
Complexity
For an already scoped frame graph, let
V/Ebe nodes/edges,R >= 1responses, andT/Sconsumed taken/skipped events. These are graph-operation bounds; frame discovery, selector/blocking-hook evaluation, templates and output/buffer processing are additional costs.O(R(V + E))graph work and gating memory, plusO(RT + S)decision/activation dispatch. The shared first-decision map itself usesO(E)memory. Each node becomes reachable once per response; there is no complete-path-count factor.O(TR log R + S(V + E))work. This is not an unconditional linear bound for the entire filter.O(E + R). The full checkpoint also includes execution IDs, render metadata and stream progress/buffers. Imported legacy residual lists retain input-sized storage and their previous per-event scan cost.Test methods and validation
Performance and behavioral equivalence are tested independently.
V=n+2,E=2n+1,paths=2^n(the middle case is 14 nodes / 25 edges / 4,096 paths). A test-side graph wrapper meters incoming/outgoing adjacency API calls and raises on the first over-budget call duringinitialize(). No timing assertions or unbounded old-path runs are needed.2RV <= 2V^2 <= 4VEfor these connected graphs (R <= V,E >= V-1,V >= 2). The conservative budget is therefore4VEprimitive invocations. Doubling stages has a limiting quadratic factor of four; both consecutive measured count ratios must be below four, and the second ratio must not exceed the first. Current initialization counts are2, 2, 2, hence ratios1, 1. API invocations exclude the work inside each accessor; the regression is not a proof of an end-to-end time bound.1024(V+E)bytes. Shared input graph/value-pool objects and code are excluded, while owned container reference slots and fixed rendering overhead are included. This bound is for fresh one-response fixtures with bounded IDs and no source buffers, not arbitrary values, stream buffers or migrated legacy paths. Derivation and measurement scope are in the implementation notes.taken_edgesmakes both cases fail at the release assertion. Eight mixed-mode input cases must raise immediately and preserve existing pending/live state; two existing-v3 input cases protect overlapping taken/rejected fields and separate observed-skip metadata.PauseCommandcheckpoint. Assert reasons, real paused-node execution identity, callback/work continuation, ordered text/selectors/final flags, no replay or loss, and final answers. Synthetic root presentation chunk UUIDs are deliberately not a continuity contract. These fixtures have empty producer buffers; the separate checkpoint tests cover buffered stream progress.git archive 069cd554tree, with production imports pointing to that tree. Result after integrating feat(response-stream): order parallel and nested replies #401: 6 failed / 10 passed. The 12/24-stage initialization aborts at 1,401 > 1,400 / 5,097 > 5,096 calls; the 6-stage retained state also exceeds its byte bound. All 9 Hypothesis differential cases pass on the old code, as expected for unchanged gating logic. Frame presentation ordering is tested separately against feat(response-stream): order parallel and nested replies #401's current contract.just test: 1,402 passed on Python 3.12.12 (two existing pandas warnings).just check: passed (lockfile, format, lint, types and import boundaries).Checklist
!No new CLA signing prompt was received during preparation.