Repository navigation
Refactor(harness): remove naive inline graph engine , unify graph execution under single pregel engine - #16608
Conversation
📝 WalkthroughWalkthroughThis PR adds shared graph interfaces and types, refactors graph construction and execution around internal implementations, wires Pregel through init-time registration, and updates harness consumers and tests to use ChangesGraph types/execution abstraction refactor
Estimated code review effort: 5 (Critical) | ~120 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
internal/harness/core/agentcore_test.go (1)
32-40: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick winGuard empty
responsesbefore indexing.&mockModel{}panics ifGenerateruns before anyaddResp; return an error instead of indexingm.responses[m.callCount].🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/harness/core/agentcore_test.go` around lines 32 - 40, The mock model Generate path in mockModel should not index m.responses when the slice is empty, since &mockModel{} can be used before any addResp call. Update Generate to guard against len(m.responses) == 0 before selecting m.responses[m.callCount], and return a non-nil error in that case; keep the existing callCount cycling logic intact for the non-empty case.
🧹 Nitpick comments (7)
internal/harness/graph/graph/graph.go (2)
358-379: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win
Compilesilently ignores options of unexpected type.
opts ...interface{}with aCompileOptiontype assertion means any mistyped/wrong option is dropped without error, masking configuration mistakes (e.g., a checkpointer or recursion limit that never takes effect). Consider returning an error for opts that aren'tCompileOption.♻️ Proposed change
for _, opt := range opts { if fn, ok := opt.(CompileOption); ok { fn(cg) + } else { + return nil, fmt.Errorf("graph: unsupported compile option type %T", opt) } }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/harness/graph/graph/graph.go` around lines 358 - 379, The Compile method on stateGraph is dropping any option that does not satisfy CompileOption, which hides configuration mistakes. Update Compile to validate each entry in opts and return an error when an unexpected option type is passed instead of silently skipping it, while keeping the existing behavior for valid CompileOption values and the cg/nodeTriggerMode setup.
381-385: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winType
WithCheckpointerascheckpoint.BaseCheckpointer
compiledGraph.checkpointeris later asserted tocheckpoint.BaseCheckpointerinGetState/GetStateHistory, so the currentinterface{}signature lets invalid values slip through and panic at runtime. Typing the option prevents that at compile time.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/harness/graph/graph/graph.go` around lines 381 - 385, The WithCheckpointer CompileOption is too loosely typed with interface{}, which allows invalid values to be set on compiledGraph.checkpointer and later panic in GetState and GetStateHistory when they assert checkpoint.BaseCheckpointer. Update WithCheckpointer to accept checkpoint.BaseCheckpointer directly, and keep the assignment in the returned closure aligned with compiledGraph.checkpointer so invalid checkpointers are rejected at compile time.internal/harness/core/setup_pregel_test.go (1)
1-4: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueStale doc comment.
The comment says "Package core_test" while the declaration is
package core, and referencesgraph.PregelRunFunc, which is nowtypes.PregelRunFunc(set viatypes.SetPregelRunFunc). Update to avoid confusion.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/harness/core/setup_pregel_test.go` around lines 1 - 4, Update the stale package comment in the setup file so it matches the actual package declaration and current API names. The comment should no longer say "Package core_test" when the file declares package core, and it should reference types.PregelRunFunc and types.SetPregelRunFunc instead of graph.PregelRunFunc. Keep the intent of explaining that importing pregel triggers init setup for compiled.Invoke(), but align the wording with the current symbols.internal/harness/graph/graph/compiled.go (1)
35-50: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value
NewCompiledStateGraphpanics on any othertypes.CompiledGraphimplementation.The signature now accepts the
types.CompiledGraphinterface, but thedefaultbranch panics for anything other than*compiledGraph/*CompiledStateGraph. Since the return type is a concrete*CompiledStateGraph(no error), a caller passing a different implementation gets a hard crash. Consider documenting this precondition clearly, or returning(*CompiledStateGraph, error)if external implementations are plausible.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/harness/graph/graph/compiled.go` around lines 35 - 50, NewCompiledStateGraph currently accepts the types.CompiledGraph interface but still panics for any implementation other than *compiledGraph or *CompiledStateGraph. Either document this constructor as only supporting those concrete types, or change NewCompiledStateGraph to return (*CompiledStateGraph, error) and handle the default case without crashing; use the NewCompiledStateGraph switch and its compiledGraph/CompiledStateGraph cases as the reference points.internal/harness/graph/graph/message.go (1)
161-171: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUnchecked type assertion on
NewStateGraphresult.
NewStateGraph(stateSchema).(*stateGraph)will panic ifNewStateGraphever returns a different concrete implementation oftypes.StateGraph. Since both live in this package the invariant holds today, but consider constructing the*stateGraphdirectly (or via an internal constructor) to avoid couplingNewMessageGraphto the assertion.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/harness/graph/graph/message.go` around lines 161 - 171, Unchecked type assertion in NewMessageGraph: NewStateGraph(stateSchema).(*stateGraph) can panic if the concrete type ever changes. Update NewMessageGraph to build the concrete stateGraph directly, or route it through an internal constructor that returns *stateGraph, so the MessageGraph setup and messagesChannel registration no longer depend on the assertion.internal/harness/core/production_stress_test.go (1)
175-182: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winSeq/par/soak blocks still discard the real error; inconsistent with the loop block's fix.
The loop-graph block (
invokeErrat Line 237) now surfaces the concrete error, but the sequential (Line 179) and parallel (Line 208) blocks still emit a genericfmt.Errorf("failed"), and the soak test (Line 339) dropsinvokeErrentirely. This makes root-causing failures in these sections harder than necessary, and is inconsistent with the described intent for this change.♻️ Proposed fix
- if invokeErr != nil { - results <- result{fmt.Sprintf("seq_%d", id), fmt.Errorf("failed"), 0} + if invokeErr != nil { + results <- result{fmt.Sprintf("seq_%d", id), invokeErr, 0} return }- if invokeErr != nil { - results <- result{fmt.Sprintf("par_%d", id), fmt.Errorf("failed"), 0} + if invokeErr != nil { + results <- result{fmt.Sprintf("par_%d", id), invokeErr, 0} return }- if invokeErr != nil { - t.Fatalf("iteration %d failed", i) + if invokeErr != nil { + t.Fatalf("iteration %d failed: %v", i, invokeErr) }Also applies to: 204-211, 335-340
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/harness/core/production_stress_test.go` around lines 175 - 182, The sequential, parallel, and soak paths in production_stress_test still hide or drop the real invokeErr, unlike the loop-graph fix. Update the result handling in runGraphAndCollect callers so the seq and par blocks propagate invokeErr instead of fmt.Errorf("failed"), and the soak block also preserves and returns the concrete error. Use the existing runGraphAndCollect, result, and invokeErr handling in production_stress_test as the anchors when making the change.internal/harness/graph/pregel/engine.go (1)
1509-1521: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAvoid mutating
inputMapwhile ranging over it.The
inputMap[guessed] = valueinsertion happens during iteration ofinputMap. Go permits this (the new entry may be produced or skipped), and it's currently harmless becauseguessedis already a registered channel and would just hit thecontinue. Still, this is a fragile pattern — collecting remaps into a side list and applying them after the loop makes intent explicit and refactor-safe.♻️ Suggested refactor
- for key, value := range inputMap { - if _, ok := registry.Get(key); ok { - continue - } - guessed := caseFoldKey(registry, key) - if guessed != "" { - delete(inputMap, key) - inputMap[guessed] = value - } else { - registry.Register(key, channels.NewLastValue(value)) - } - } + remaps := make(map[string]string) + for key := range inputMap { + if _, ok := registry.Get(key); ok { + continue + } + if guessed := caseFoldKey(registry, key); guessed != "" { + remaps[key] = guessed + } else { + registry.Register(key, channels.NewLastValue(inputMap[key])) + } + } + for from, to := range remaps { + inputMap[to] = inputMap[from] + delete(inputMap, from) + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/harness/graph/pregel/engine.go` around lines 1509 - 1521, Avoid mutating inputMap during its own range loop in the engine write path. In the input-registration block that uses registry.Get, caseFoldKey, and channels.NewLastValue, collect any key remaps (and registrations) in a temporary list while iterating, then apply the delete/insert or registry.Register actions after the loop. This keeps the behavior the same but makes the intent explicit and avoids fragile iteration-time map writes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/harness/graph/graph/graph_enterprise_integration_test.go`:
- Line 269: The Pregel skip in the enterprise graph integration tests should be
removed so these cases keep running until exact parity exists. Update the test
setup in TestEnterprise_ConditionalEdge_MultiWay and
TestEnterprise_DAGWithConditionalEdge so they are not gated by the t.Skip in
graph_enterprise_integration_test.go, and keep them enabled against the current
graph engine coverage rather than deferring entirely to Pregel. If parity is
still incomplete, add or adapt the existing enterprise assertions instead of
skipping the tests.
In `@internal/harness/graph/graph/state_inspector.go`:
- Line 80: Guard the direct checkpoint.BaseCheckpointer type assertion in
StateInspector methods before calling any checkpointer operations, since
compiledGraph.checkpointer is an interface and WithCheckpointer allows
non-BaseCheckpointer values that can panic. Update the StateInspector methods
that currently use cg.checkpointer.(checkpoint.BaseCheckpointer), especially
UpdateState and ForkThread, to perform a comma-ok assertion once, return a
descriptive error if the cast fails, and reuse the typed value for the
subsequent Get/Put/List calls.
In `@internal/harness/graph/pregel/init_pregel.go`:
- Around line 16-42: runCompiledGraph is ignoring the requested stream mode, so
compiledGraph.Stream(...) cannot produce the correct streaming shape. Update
runCompiledGraph to pass streamMode through to the Pregel engine instead of
always calling engine.RunSync, using the existing runCompiledGraph and
NewEngine/engine execution path to route StreamMode* requests correctly.
---
Outside diff comments:
In `@internal/harness/core/agentcore_test.go`:
- Around line 32-40: The mock model Generate path in mockModel should not index
m.responses when the slice is empty, since &mockModel{} can be used before any
addResp call. Update Generate to guard against len(m.responses) == 0 before
selecting m.responses[m.callCount], and return a non-nil error in that case;
keep the existing callCount cycling logic intact for the non-empty case.
---
Nitpick comments:
In `@internal/harness/core/production_stress_test.go`:
- Around line 175-182: The sequential, parallel, and soak paths in
production_stress_test still hide or drop the real invokeErr, unlike the
loop-graph fix. Update the result handling in runGraphAndCollect callers so the
seq and par blocks propagate invokeErr instead of fmt.Errorf("failed"), and the
soak block also preserves and returns the concrete error. Use the existing
runGraphAndCollect, result, and invokeErr handling in production_stress_test as
the anchors when making the change.
In `@internal/harness/core/setup_pregel_test.go`:
- Around line 1-4: Update the stale package comment in the setup file so it
matches the actual package declaration and current API names. The comment should
no longer say "Package core_test" when the file declares package core, and it
should reference types.PregelRunFunc and types.SetPregelRunFunc instead of
graph.PregelRunFunc. Keep the intent of explaining that importing pregel
triggers init setup for compiled.Invoke(), but align the wording with the
current symbols.
In `@internal/harness/graph/graph/compiled.go`:
- Around line 35-50: NewCompiledStateGraph currently accepts the
types.CompiledGraph interface but still panics for any implementation other than
*compiledGraph or *CompiledStateGraph. Either document this constructor as only
supporting those concrete types, or change NewCompiledStateGraph to return
(*CompiledStateGraph, error) and handle the default case without crashing; use
the NewCompiledStateGraph switch and its compiledGraph/CompiledStateGraph cases
as the reference points.
In `@internal/harness/graph/graph/graph.go`:
- Around line 358-379: The Compile method on stateGraph is dropping any option
that does not satisfy CompileOption, which hides configuration mistakes. Update
Compile to validate each entry in opts and return an error when an unexpected
option type is passed instead of silently skipping it, while keeping the
existing behavior for valid CompileOption values and the cg/nodeTriggerMode
setup.
- Around line 381-385: The WithCheckpointer CompileOption is too loosely typed
with interface{}, which allows invalid values to be set on
compiledGraph.checkpointer and later panic in GetState and GetStateHistory when
they assert checkpoint.BaseCheckpointer. Update WithCheckpointer to accept
checkpoint.BaseCheckpointer directly, and keep the assignment in the returned
closure aligned with compiledGraph.checkpointer so invalid checkpointers are
rejected at compile time.
In `@internal/harness/graph/graph/message.go`:
- Around line 161-171: Unchecked type assertion in NewMessageGraph:
NewStateGraph(stateSchema).(*stateGraph) can panic if the concrete type ever
changes. Update NewMessageGraph to build the concrete stateGraph directly, or
route it through an internal constructor that returns *stateGraph, so the
MessageGraph setup and messagesChannel registration no longer depend on the
assertion.
In `@internal/harness/graph/pregel/engine.go`:
- Around line 1509-1521: Avoid mutating inputMap during its own range loop in
the engine write path. In the input-registration block that uses registry.Get,
caseFoldKey, and channels.NewLastValue, collect any key remaps (and
registrations) in a temporary list while iterating, then apply the delete/insert
or registry.Register actions after the loop. This keeps the behavior the same
but makes the intent explicit and avoids fragile iteration-time map writes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 254329ba-c5b6-4c5c-bf1c-6a8fd82c1877
📒 Files selected for processing (45)
internal/harness/core/agentcore_test.gointernal/harness/core/graph_integration_test.gointernal/harness/core/multiagent_integration_test.gointernal/harness/core/production_stress_test.gointernal/harness/core/react_agent.gointernal/harness/core/react_graph.gointernal/harness/core/setup_pregel_test.gointernal/harness/core/subagent_node.gointernal/harness/core/subagent_node_test.gointernal/harness/core/workflow_graph.gointernal/harness/core/workflow_graph_test.gointernal/harness/graph/channels/reducer.gointernal/harness/graph/graph/checkpoint_recovery_test.gointernal/harness/graph/graph/compiled.gointernal/harness/graph/graph/graph.gointernal/harness/graph/graph/graph_advanced_fault_edge_test.gointernal/harness/graph/graph/graph_channel_test.gointernal/harness/graph/graph/graph_checkpoint_migration_test.gointernal/harness/graph/graph/graph_concurrency_test.gointernal/harness/graph/graph/graph_enterprise_integration_test.gointernal/harness/graph/graph/graph_integration_test.gointernal/harness/graph/graph/graph_persistence_evolution_test.gointernal/harness/graph/graph/graph_subgraph_state_test.gointernal/harness/graph/graph/graph_test.gointernal/harness/graph/graph/graph_time_travel_test.gointernal/harness/graph/graph/graph_timetravel_send_test.gointernal/harness/graph/graph/graph_topology_checkpoint_edge_test.gointernal/harness/graph/graph/loop.gointernal/harness/graph/graph/message.gointernal/harness/graph/graph/parallel.gointernal/harness/graph/graph/state.gointernal/harness/graph/graph/state_inspector.gointernal/harness/graph/graph/state_inspector_test.gointernal/harness/graph/pregel/engine.gointernal/harness/graph/pregel/engine_test.gointernal/harness/graph/pregel/init_pregel.gointernal/harness/graph/pregel/pregel_async_stream_edge_test.gointernal/harness/graph/pregel/pregel_durability_timetravel_test.gointernal/harness/graph/pregel/pregel_fault_edge_test.gointernal/harness/graph/pregel/pregel_perf_benchmark_test.gointernal/harness/graph/pregel/pregel_pressure_test.gointernal/harness/graph/pregel/subgraph.gointernal/harness/graph/task/decorator.gointernal/harness/graph/types/types.gointernal/harness/harness.go
|
|
||
| // TestEnterprise_ConditionalEdge_MultiWay verifies a 3-way conditional edge. | ||
| func TestEnterprise_ConditionalEdge_MultiWay(t *testing.T) { | ||
| t.Skip("requires Pregel engine - see pregel/ for equivalent tests") |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check pregel/ tests for equivalent multi-way conditional-edge and DAG-conditional coverage
rg -n -i 'conditionaledge|multiway|dagwithconditional' internal/harness/graph/pregel --type=goRepository: infiniflow/ragflow
Length of output: 1328
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '220,320p' internal/harness/graph/graph/graph_enterprise_integration_test.go
printf '\n---\n'
sed -n '520,580p' internal/harness/graph/graph/graph_enterprise_integration_test.go
printf '\n=== PREGEL ===\n'
sed -n '600,700p' internal/harness/graph/pregel/pregel_pressure_test.go
printf '\n---\n'
sed -n '1500,1575p' internal/harness/graph/pregel/pregel_pressure_test.goRepository: infiniflow/ragflow
Length of output: 10234
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -i 'path_c|3-way|multi-way|multiway|AddConditionalEdges\(' internal/harness/graph/pregel --type=goRepository: infiniflow/ragflow
Length of output: 985
Keep these tests enabled until Pregel has exact parity
TestEnterprise_ConditionalEdge_MultiWay still has no matching 3-way Pregel case, and TestEnterprise_DAGWithConditionalEdge only lines up with a simpler 2-branch DAG. The current skip hides coverage for these shapes at internal/harness/graph/graph/graph_enterprise_integration_test.go:269, 542.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@internal/harness/graph/graph/graph_enterprise_integration_test.go` at line
269, The Pregel skip in the enterprise graph integration tests should be removed
so these cases keep running until exact parity exists. Update the test setup in
TestEnterprise_ConditionalEdge_MultiWay and
TestEnterprise_DAGWithConditionalEdge so they are not gated by the t.Skip in
graph_enterprise_integration_test.go, and keep them enabled against the current
graph engine coverage rather than deferring entirely to Pregel. If parity is
still incomplete, add or adapt the existing enterprise assertions instead of
skipping the tests.
| func runCompiledGraph( | ||
| ctx context.Context, | ||
| cg types.CompiledGraph, | ||
| input interface{}, | ||
| config *types.RunnableConfig, | ||
| streamMode types.StreamMode, | ||
| ) (interface{}, error) { | ||
| interruptKeys := make([]string, 0, len(cg.GetInterrupts())) | ||
| for k := range cg.GetInterrupts() { | ||
| interruptKeys = append(interruptKeys, k) | ||
| } | ||
| interruptAfterKeys := make([]string, 0, len(cg.GetInterruptsAfter())) | ||
| for k := range cg.GetInterruptsAfter() { | ||
| interruptAfterKeys = append(interruptAfterKeys, k) | ||
| } | ||
|
|
||
| cp, _ := cg.GetCheckpointer().(checkpoint.BaseCheckpointer) | ||
| engine := NewEngine(cg.GetGraph(), | ||
| WithCheckpointer(cp), | ||
| WithInterrupts(interruptKeys...), | ||
| WithInterruptsAfter(interruptAfterKeys...), | ||
| WithRecursionLimit(cg.GetRecursionLimit()), | ||
| WithDebug(cg.IsDebug()), | ||
| WithConfig(config), | ||
| ) | ||
| return engine.RunSync(ctx, input) | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Where is PregelRunFunc invoked, and does Stream route through it with streamMode?
rg -nP 'PregelRunFunc|func .*\brun\b\(' internal/harness/graph/graph/compiled.go
rg -nP 'func .*compiledGraph.*Stream\(' internal/harness/graph/graph/compiled.go -A 15Repository: infiniflow/ragflow
Length of output: 156
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Locate the relevant graph/compiled files and inspect the call path for runCompiledGraph.
fd -a 'compiled.go|init_pregel.go' internal/harness/graph
printf '\n--- init_pregel.go ---\n'
wc -l internal/harness/graph/pregel/init_pregel.go
cat -n internal/harness/graph/pregel/init_pregel.go | sed -n '1,140p'
printf '\n--- compiled.go candidates ---\n'
fd -a 'compiled.go' internal/harness/graphRepository: infiniflow/ragflow
Length of output: 1880
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n--- compiled.go outline ---\n'
ast-grep outline internal/harness/graph/graph/compiled.go --view expanded || true
printf '\n--- search for PregelRunFunc / Stream / runCompiledGraph ---\n'
rg -n "PregelRunFunc|SetPregelRunFunc|runCompiledGraph|streamMode|func .*Stream\(" internal/harness/graph -A 6 -B 4
printf '\n--- relevant type definitions ---\n'
fd -a 'types.go' internal/harness/graph
rg -n "type PregelRunFunc|type StreamMode|func .*Invoke|func .*Stream\(" internal/harness/graph/types -A 8 -B 4Repository: infiniflow/ragflow
Length of output: 35084
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n--- graph.go Stream/run ---\n'
sed -n '420,470p' internal/harness/graph/graph/graph.go
printf '\n--- pregel engine methods ---\n'
rg -n "func .*RunSync|func .*Run\(" internal/harness/graph/pregel -A 20 -B 6
printf '\n--- search for streamMode use in pregel engine ---\n'
rg -n "streamMode|StreamMode" internal/harness/graph/pregel -A 4 -B 4Repository: infiniflow/ragflow
Length of output: 50374
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n--- engine recursion limit defaults/options ---\n'
rg -n "recursionLimit|WithRecursionLimit|NewEngine\(" internal/harness/graph/pregel/engine.go internal/harness/graph/pregel -A 6 -B 4
printf '\n--- compiled graph recursion limit plumbing ---\n'
rg -n "GetRecursionLimit\(|recursionLimit" internal/harness/graph/graph internal/harness/graph/types -A 4 -B 4
printf '\n--- any zero-limit tests or guards ---\n'
rg -n "RecursionLimit.*0|WithRecursionLimit\(0\)|recursion limit" internal/harness/graph -A 4 -B 4Repository: infiniflow/ragflow
Length of output: 50375
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '124,180p' internal/harness/graph/graph/compiled.goRepository: infiniflow/ragflow
Length of output: 1776
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n--- compiled graph stream tests/usages ---\n'
rg -n "CompiledStateGraph.*Stream|\.Stream\(ctx, .*StreamMode|StreamModeUpdates|StreamModeTasks|StreamModeCheckpoints" internal/harness/graph/graph internal/harness/graph/pregel -A 4 -B 4
printf '\n--- pregel stream-mode expectations in tests ---\n'
sed -n '1,180p' internal/harness/graph/pregel/pregel_stream_retry_integration_test.goRepository: infiniflow/ragflow
Length of output: 13606
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '250,320p' internal/harness/graph/graph/graph_integration_test.goRepository: infiniflow/ragflow
Length of output: 2104
Forward streamMode to the Pregel engine
compiledGraph.Stream(...) passes the requested mode into this hook, but runCompiledGraph ignores it and always calls engine.RunSync(...). That collapses every StreamMode* request into a single final result instead of the requested stream shape.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@internal/harness/graph/pregel/init_pregel.go` around lines 16 - 42,
runCompiledGraph is ignoring the requested stream mode, so
compiledGraph.Stream(...) cannot produce the correct streaming shape. Update
runCompiledGraph to pass streamMode through to the Pregel engine instead of
always calling engine.RunSync, using the existing runCompiledGraph and
NewEngine/engine execution path to route StreamMode* requests correctly.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/harness/graph/graph/state_inspector.go`:
- Around line 233-241: The fallback path in the checkpoint update flow returns
the original config, which can leave callers pointing at the old checkpoint
instead of the newly created one. In the state inspector’s checkpoint update
logic, update the `err != nil || len(entries) == 0` branch to return a config
that includes `newThreadID` (and the new checkpoint identity if available)
rather than the input `config`, so the caller always advances to the updated
checkpoint even when `cp.List` fails or returns no entries.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8827b7ca-179c-4af9-bb64-b7a1814bd3e1
📒 Files selected for processing (1)
internal/harness/graph/graph/state_inspector.go
| if err := cp.Put(ctx, newConfig, cpData); err != nil { | ||
| return nil, fmt.Errorf("failed to save updated checkpoint: %w", err) | ||
| } | ||
|
|
||
| // 4. Return the config for the new checkpoint. | ||
| listCfg := map[string]interface{}{ | ||
| constants.ConfigKeyThreadID: newThreadID, | ||
| } | ||
| entries, err := cg.checkpointer.List(ctx, listCfg, 1) | ||
| entries, err := cp.List(ctx, listCfg, 1) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify List ordering (newest first?) and whether callers depend on the returned config id.
sed -n '600,700p' internal/harness/graph/checkpoint/checkpoint.go
rg -nP '\.UpdateState\s*\(' internal/harness --type=go -C2Repository: infiniflow/ragflow
Length of output: 7363
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the relevant implementation and nearby helpers.
sed -n '180,290p' internal/harness/graph/graph/state_inspector.go
printf '\n---\n'
sed -n '1,220p' internal/harness/graph/graph/state_inspector_test.go
printf '\n---\n'
sed -n '1,220p' internal/harness/graph/checkpoint/checkpoint.goRepository: infiniflow/ragflow
Length of output: 16828
Return a config with the new checkpoint on the fallback path
List(limit=1) is newest-first, but the err != nil || len(entries) == 0 path falls back to the input config, which leaves callers on the pre-update checkpoint. Return at least a config carrying newThreadID instead of the original config here.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@internal/harness/graph/graph/state_inspector.go` around lines 233 - 241, The
fallback path in the checkpoint update flow returns the original config, which
can leave callers pointing at the old checkpoint instead of the newly created
one. In the state inspector’s checkpoint update logic, update the `err != nil ||
len(entries) == 0` branch to return a config that includes `newThreadID` (and
the new checkpoint identity if available) rather than the input `config`, so the
caller always advances to the updated checkpoint even when `cp.List` fails or
returns no entries.
…cution under single pregel engine (infiniflow#16608)
…cution under single pregel engine (infiniflow#16608)
No description provided.