Skip to content

refactor(go): remove resume/checkpoint feature - #18170

Closed
jay77721 wants to merge 1 commit into
infiniflow:mainfrom
jay77721:remove-go-resume
Closed

jay77721 wants to merge 1 commit into
infiniflow:mainfrom
jay77721:remove-go-resume

Conversation

@jay77721

Copy link
Copy Markdown
Member

Summary

Removes the Go-side resume feature entirely. We are cancelling this feature, so all Go code, DSL fixtures, and the resume/CV builtin pipeline template are deleted. The Python side (api/, rag/app/resume.py, agent templates) is intentionally untouched.

What was removed

DSL JSON

  • internal/ingestion/pipeline/template/ingestion_pipeline_resume.json (resume builtin template, parser_id="resume")
  • internal/agent/dsl/testdata/resume.json

Whole files

  • internal/agent/canvas/interrupt_resume.go (+ test) — eino interrupt/resume wrappers, UserFillUpNodeBody
  • internal/agent/canvas/run_tracker.go (+ test) — Redis RunTracker
  • internal/agent/canvas/checkpoint_store.go (+ test) — Redis CheckPointStore
  • internal/agent/canvas/state_serializer.go (+ test) — CanvasStateSerializer
  • internal/handler/agent_wait_for_user_test.go
  • internal/agent/workflowx/r3_interrupt_test.go

In-file removals

  • Ingestion pipeline: WithRequireResume, ErrResumeUnavailable, WithCheckPointStore/WithRunTracker, runResumable, DSL fingerprinting (guardDSLChange), cleanupCheckpoint; Pipeline.Run now always runs a single non-resumable invoke (runPlain → run)
  • Agent canvas: checkpoint/serializer/interrupt compile options, runner saveInterruptID/getInterruptID/Peek and waiting_for_user handling, UserFillUp interrupt routing (UserFillUp now goes through the normal component path)
  • service/agent.go / handler/agent.go / cmd/ragflow_server.go: runTracker/checkpointStore/stateSerializer fields and all __resume_*/compose.ResumeWithData resume paths; wait-for-user form-input extraction
  • workflowx loop/parallel: resume snapshot/checkpoint machinery (ErrLoopResumeStateInvalid, ErrParallelResumeStateInvalid, bridge stores, parallelResumeBackdoorKey, replay)
  • Resume parser registration: ParserTypeResume, "resume" in parser config, resume:Resume in parser_ids strings, related tests

Not touched (per scope)

  • internal/channels/qqbot.go — QQ gateway WebSocket session resume (protocol-level)
  • internal/harness/** — standalone graph framework with its own resume concepts
  • "resume the conversation" via session_id (normal chat continuation)

Validation

  • bash build.sh --test ./... passes (full Go unit suite)
  • gofmt clean on all modified files

Remove the Go-side resume feature: ingestion pipeline checkpoint/resume,
agent canvas eino interrupt/resume with Redis checkpointing (RunTracker,
CheckPointStore, StateSerializer, wait-for-user), and the resume/CV
builtin pipeline template plus its parser_id registration.

Deleted files:
- internal/ingestion/pipeline/template/ingestion_pipeline_resume.json
- internal/agent/dsl/testdata/resume.json
- internal/agent/canvas/{interrupt_resume,run_tracker,checkpoint_store,state_serializer}.go (+ tests)
- internal/handler/agent_wait_for_user_test.go
- internal/agent/workflowx/r3_interrupt_test.go

The ingestion pipeline now always runs a single non-resumable Invoke
(runPlain became run), and the agent canvas no longer pauses/resumes on
UserFillUp. loop/parallel workflowx helpers lost their resume snapshot
and checkpoint machinery. resume parser registration (ParserTypeResume,
parser_ids strings, parser_config) and its tests were dropped too.

Validated with: bash build.sh --test ./...
@dosubot dosubot Bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Aug 12, 2026
@jay77721
jay77721 requested review from xugangqiang and yuzhichang and removed request for yuzhichang August 12, 2026 09:05
@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The pull request removes checkpoint, interrupt, resume, and distributed run-tracking support from canvas execution, workflow extensions, agent services, and ingestion pipelines. It also removes resume parser configuration and structured agent input handling.

Changes

Resume infrastructure removal

Layer / File(s) Summary
Simplify canvas compilation and execution
internal/agent/canvas/compile.go, internal/agent/canvas/node_body.go, internal/agent/canvas/runner.go, internal/agent/canvas/runner_cancel_test.go
Canvas compilation and runner execution no longer use checkpoint or interrupt state.
Remove loop and parallel resume paths
internal/agent/workflowx/loop.go, internal/agent/workflowx/parallel.go, internal/agent/workflowx/*_test.go
Loop and parallel execution now invoke and stream directly without replay or checkpoint bridging.
Use local agent execution state
cmd/ragflow_server.go, internal/service/agent.go, internal/service/*_test.go
Agent execution no longer injects Redis checkpoints, leases, or run trackers. Cancellation uses local session state.
Run ingestion without resume requirements
internal/ingestion/pipeline/*, internal/ingestion/service/*, internal/ingestion/task/*, internal/common/parser_config.go, internal/entity/dataset.go
Ingestion runs once without checkpoint stores, resume fingerprints, or required-resume options.
Update input and supporting contracts
internal/handler/agent.go, internal/agent/runtime/*, internal/agent/component/fixture_stubs.go, internal/ingestion/component/*
Structured form-input fallback and resume-specific documentation were removed or generalized.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

Suggested labels: ☯️ refactor

Suggested reviewers: euvre, yingfeng, jinhai-cn

Poem

I’m a rabbit with a cleaner run,
No checkpoint clouds to block the sun.
Loops hop forward, streams flow bright,
Local sessions keep things light.
Resume paths rest beneath the moon—
Fresh workflows finish soon.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 70.42% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description includes the required Summary section and clearly explains the scope, removals, exclusions, and validation results.
Title check ✅ Passed The title is concise and accurately identifies the main change: removing the Go resume and checkpoint features.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jay77721 jay77721 added the ci Continue Integration label Aug 12, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
internal/agent/workflowx/parallel_options_test.go (1)

115-135: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Make compile-option forwarding observable. store.Get reads the test-local map directly, so it does not prove that WithParallelCompileOptions reached sub.Compile. Replace the checkpoint option with a non-checkpoint compile option whose effect the test can assert.

🤖 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/agent/workflowx/parallel_options_test.go` around lines 115 - 135,
Update TestOptions_ParallelCompileOptionsForwarded to replace
WithParallelCompileOptions(compose.WithCheckPointStore(store)) and the direct
store.Get check with a non-checkpoint compile option whose runtime effect is
observable in the test. Assert that effect after AddParallelNode compiles the
sub-workflow, ensuring the option was forwarded to sub.Compile rather than
merely using the test-local store.
internal/service/agent.go (1)

313-316: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Update the stale runner field comment.

The comment names the field driver, but the field is runner. It also states "V1 persistence is in-memory; a follow-up phase moves to Redis per plan §4.9". This PR removes the Redis checkpoint path, so the note now describes a plan that no longer exists.

As per coding guidelines: "Remove commented-out Go code instead of leaving recovery notes, and keep package and doc comments aligned with the current runtime path rather than migration history."

📝 Proposed comment fix
-	// driver is the per-process runner that drives canvas
-	// invocations and produces SSE events. V1 persistence is
-	// in-memory; a follow-up phase moves to Redis per plan §4.9.
+	// runner is the per-process runner that drives canvas
+	// invocations and produces SSE events. Run state is local to
+	// this process.
 	runner *canvas.Runner
🤖 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/service/agent.go` around lines 313 - 316, Update the documentation
comment immediately above the runner field to identify runner correctly and
describe only its current role in driving canvas invocations and producing SSE
events. Remove the obsolete in-memory persistence and Redis migration-history
statements.

Source: Coding guidelines

internal/handler/agent.go (1)

1071-1079: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Preserve inputs in /api/v1/agents/chat/completions.

The web client sends inputs for Begin operator values, but AgentChatCompletions drops this field and forwards only query or message content to RunAgent. Restore structured input propagation and add a contract test.

🤖 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/handler/agent.go` around lines 1071 - 1079, Update
agentChatCompletionsRequest and the AgentChatCompletions flow to accept and
preserve the client’s structured inputs for Begin operator values, forwarding
them to RunAgent alongside the existing query or message content. Ensure inputs
are retained for both supported request formats, and add a contract test
verifying /api/v1/agents/chat/completions propagates them correctly.
🧹 Nitpick comments (8)
internal/ingestion/pipeline/pipeline.go (1)

210-227: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Inline the single-caller run helper into Run.

run existed to support the repeated resumable invocation loop. After the removal, it has one caller and takes four parameters that Run already holds. Inline it to keep one execution path in this file.

Based on learnings and coding guidelines for internal/{ingestion,parser,deepdoc}/**/*.go: "In actively refactored Go ingestion, parser, and DeepDOC code, collapse duplicate paths rather than preserving transitional wrappers."

♻️ Proposed inlining
-	return p.run(runCtx, current, compiled, runState)
-}
-
-// run executes a single Invoke of the compiled workflow, records progress via
-// the sink, and returns the merged output.
-func (p *Pipeline) run(runCtx context.Context, current map[string]any, compiled *canvas.CompiledCanvas, runState *canvas.CanvasState) (map[string]any, error) {
 	out, err := compiled.Workflow.Invoke(runCtx, current)
 	if err != nil {
 		if errors.Is(runCtx.Err(), context.Canceled) || errors.Is(runCtx.Err(), context.DeadlineExceeded) {
 			return current, fmt.Errorf("pipeline: run cancelled: %w", runCtx.Err())
 		}
 		return current, fmt.Errorf("pipeline: run canvas workflow: %w", err)
 	}
 	return finalizeResult(current, out, runState), nil
 }
🤖 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/ingestion/pipeline/pipeline.go` around lines 210 - 227, Remove the
single-caller Pipeline.run helper and inline its workflow invocation,
cancellation handling, error wrapping, and finalizeResult call directly into
Run’s invocation loop, using Run’s existing runCtx, current, compiled, and
runState variables. Preserve the current return values and error behavior while
leaving finalizeResult unchanged.

Sources: Coding guidelines, Learnings

internal/service/user.go (1)

206-206: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Default ParserIDs is duplicated in two tenant-creation paths and the two copies disagree. This PR removed resume:Resume from both literals, but the copies still differ: one includes tag:Tag and labels paper as "Research Paper", the other omits tag:Tag and labels paper as "Paper". Tenants therefore get different parser sets depending on the creation path.

  • internal/service/user.go#L206-L206: replace the inline literal with a shared exported default (for example entity.DefaultParserIDs) and keep this list as the single source of truth.
  • internal/admin/service.go#L255-L255: use the same shared default instead of the local literal, or document why the admin path must omit tag:Tag.
🤖 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/service/user.go` at line 206, Define one exported default ParserIDs
value, such as entity.DefaultParserIDs, as the single source of truth and update
internal/service/user.go:206-206 to use it instead of the inline literal. Update
internal/admin/service.go:255-255 to use the same shared default, preserving the
consistent parser set including tag:Tag and the “Research Paper” label.
internal/agent/workflowx/parallel.go (1)

185-204: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove the dead nodeKey parameter threaded through the parallel helpers. Checkpoint-ID and address-segment generation was the only consumer of nodeKey. After this removal, neither helper reads the value, and Go does not report unused function parameters. Both helpers are unexported, so the cleanup stays inside internal/agent/workflowx.

  • internal/agent/workflowx/parallel.go#L185-L204: delete the nodeKey string parameter from runParallelInvoke and drop it from the runParallelFanout call at Line 204.
  • internal/agent/workflowx/parallel.go#L258-L265: delete the nodeKey string parameter from runParallelFanout; the body never reads it.
  • internal/agent/workflowx/parallel_test.go#L218-L218: remove the "par" argument from the runParallelFanout call.
  • internal/agent/workflowx/parallel_test.go#L268-L268: remove the "par" argument from the runParallelInvoke call.
  • internal/agent/workflowx/parallel_test.go#L367-L367: remove the "par" argument from the runParallelInvoke call.

Also update the AddParallelNode call site at internal/agent/workflowx/parallel.go Line 155, which passes key.

Based on coding guidelines: "Treat legacy code as a liability rather than a compatibility target; prefer deletion over shims, deprecated branches, wrapper APIs, and dual-track migrations."

🤖 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/agent/workflowx/parallel.go` around lines 185 - 204, Remove the
unused nodeKey parameter from runParallelInvoke and runParallelFanout, and stop
forwarding it between them; also update the AddParallelNode call site in
internal/agent/workflowx/parallel.go (Line 155) to omit key. In
internal/agent/workflowx/parallel_test.go (Line 218, Line 268, and Line 367),
remove the "par" argument from the affected helper calls. Do not add
compatibility wrappers or shims.

Source: Coding guidelines

internal/agent/workflowx/loop.go (1)

336-372: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

Close the buffered iteration readers that sendIterations never consumes.

streamReaders accumulates one schema.StreamReader[T] per iteration at Line 372. Two paths leave some of those readers unclosed:

  • In LoopStreamFinalOnly mode, sendIterations emits and closes only the last reader. All earlier readers stay open.
  • In the case err := <-pipeErrCh: branch with LoopStreamFinalOnly, sendIterations is not called at all. Every collected reader stays open.

The readers come from schema.StreamReaderFromArray, so the practical cost is bounded. Closing them still keeps the code aligned with the eino stream contract and avoids a real leak if the reader source ever changes.

♻️ Proposed cleanup for unconsumed readers
 	go func() {
 		defer outWriter.Close()
 		select {
 		case <-allClosed:
 			// Produce finished; emit the iteration streams
 			// according to streamMode, then signal any error
 			// from the goroutine.
 			sendIterations(streamReaders, streamMode, outWriter)
+			closeUnsentIterations(streamReaders, streamMode)
 			// Drain any pending error from produce.
 			select {
 			case err := <-pipeErrCh:
 				if err != nil {
 					outWriter.Send(zero, err)
 				}
 			default:
 			}
 		case err := <-pipeErrCh:
 			// Produce emitted an error before closing; the
 			// readers produced so far are still useful only
 			// for LoopStreamEveryIteration. Re-emit them,
 			// then surface the error.
 			if streamMode == LoopStreamEveryIteration {
 				sendIterations(streamReaders, streamMode, outWriter)
+			} else {
+				for _, r := range streamReaders {
+					r.Close()
+				}
 			}
 			outWriter.Send(zero, err)
 		}
 	}()

Add the helper next to sendIterations:

// closeUnsentIterations releases the readers that sendIterations
// skipped for the given mode.
func closeUnsentIterations[T any](readers []*schema.StreamReader[T], mode LoopStreamMode) {
	if mode != LoopStreamFinalOnly || len(readers) <= 1 {
		return
	}
	for _, r := range readers[:len(readers)-1] {
		r.Close()
	}
}

Also applies to: 397-423

🤖 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/agent/workflowx/loop.go` around lines 336 - 372, Close buffered
iteration readers that are not consumed in LoopStreamFinalOnly mode. Add a
closeUnsentIterations helper near sendIterations, invoke it after sendIterations
where earlier readers are skipped, and invoke it in the pipeErrCh path before
returning when sendIterations is not called; preserve existing behavior for
other modes and the final reader.
internal/agent/workflowx/loop_integration_test.go (1)

65-79: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove the unused drainStreamUntilError helper.

readAllInts is the only equivalent helper with active call sites.

🤖 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/agent/workflowx/loop_integration_test.go` around lines 65 - 79,
Remove the unused drainStreamUntilError helper function, including its entire
implementation; retain readAllInts and its existing call sites unchanged.

Source: Coding guidelines

internal/service/agent_cancel_test.go (1)

64-90: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Align the test name with the assertions, or restore the marker assertion.

The test is named TestCancelSessionRunFinishedSessionDoesNotCreateCancelMarker, but it no longer checks any cancel marker. It only checks that no local active entry appears. The name now describes coverage that does not exist.

CancelSessionRun documents that it must not publish a session-scoped marker for a non-active session. That invariant is worth keeping under test. Either assert it with canvas.CancelRequested, or rename the test to match what it verifies.

🤖 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/service/agent_cancel_test.go` around lines 64 - 90, Update
TestCancelSessionRunFinishedSessionDoesNotCreateCancelMarker to assert that
cancelling the persisted and missing sessions does not publish a session-scoped
canvas.CancelRequested marker, preserving the existing local active-entry
assertion; alternatively, rename the test to accurately describe only the local
active-session behavior it currently verifies.
internal/service/agent_run_e2e_test.go (1)

23-24: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove the unused collectEventTypes helper. It has no callers. The other checked helpers remain in use.

🤖 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/service/agent_run_e2e_test.go` around lines 23 - 24, Remove the
unused collectEventTypes helper from the agent run E2E test file, leaving the
other checked helpers and failure-path tests unchanged.

Source: Coding guidelines

internal/agent/canvas/runner.go (1)

198-205: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Return only error from safeInvoke. Run is the only caller, and it discards the *CanvasState result. Remove the unused state variable and return value from safeInvoke.

🤖 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/agent/canvas/runner.go` around lines 198 - 205, Update safeInvoke
and its sole caller Run to return and handle only an error; remove the discarded
*CanvasState result and the corresponding unused state variable while preserving
the existing cancellation and pushErr handling.
🤖 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/agent/canvas/runner.go`:
- Around line 28-36: Update the normal-completion documentation near Run to
state that Runner closes the channel after buildRunFunc completes, while the
HTTP handler emits the done frame when it observes channel closure; do not claim
that Runner sends the done terminator directly. Keep the cancellation and error
outcome descriptions unchanged.

In `@internal/agent/runtime/state.go`:
- Around line 133-140: Correct the documentation for MarshalJSON to state that
RLock is held through SafeJSONMarshal, allowing readers but blocking writers
such as SetVar; clarify that snap initially references existing maps and slices
before SafeJSONMarshal copies and cleans them, and that atomic.Bool serializes
as {} rather than 8 bytes.

In `@internal/ingestion/pipeline/pipeline.go`:
- Around line 213-214: Update the doc comment for the run helper to remove the
claim that it records progress via the sink. Describe only that it invokes the
compiled workflow once and returns the merged output, leaving progress reporting
to Run and the framework callback.

In `@internal/service/canvas_decode_test.go`:
- Around line 270-271: Correct the doc comment for
TestNewAgentService_ConstructsPins by inserting the missing space so it reads
naturally as a description of the test constructing pins.

---

Outside diff comments:
In `@internal/agent/workflowx/parallel_options_test.go`:
- Around line 115-135: Update TestOptions_ParallelCompileOptionsForwarded to
replace WithParallelCompileOptions(compose.WithCheckPointStore(store)) and the
direct store.Get check with a non-checkpoint compile option whose runtime effect
is observable in the test. Assert that effect after AddParallelNode compiles the
sub-workflow, ensuring the option was forwarded to sub.Compile rather than
merely using the test-local store.

In `@internal/handler/agent.go`:
- Around line 1071-1079: Update agentChatCompletionsRequest and the
AgentChatCompletions flow to accept and preserve the client’s structured inputs
for Begin operator values, forwarding them to RunAgent alongside the existing
query or message content. Ensure inputs are retained for both supported request
formats, and add a contract test verifying /api/v1/agents/chat/completions
propagates them correctly.

In `@internal/service/agent.go`:
- Around line 313-316: Update the documentation comment immediately above the
runner field to identify runner correctly and describe only its current role in
driving canvas invocations and producing SSE events. Remove the obsolete
in-memory persistence and Redis migration-history statements.

---

Nitpick comments:
In `@internal/agent/canvas/runner.go`:
- Around line 198-205: Update safeInvoke and its sole caller Run to return and
handle only an error; remove the discarded *CanvasState result and the
corresponding unused state variable while preserving the existing cancellation
and pushErr handling.

In `@internal/agent/workflowx/loop_integration_test.go`:
- Around line 65-79: Remove the unused drainStreamUntilError helper function,
including its entire implementation; retain readAllInts and its existing call
sites unchanged.

In `@internal/agent/workflowx/loop.go`:
- Around line 336-372: Close buffered iteration readers that are not consumed in
LoopStreamFinalOnly mode. Add a closeUnsentIterations helper near
sendIterations, invoke it after sendIterations where earlier readers are
skipped, and invoke it in the pipeErrCh path before returning when
sendIterations is not called; preserve existing behavior for other modes and the
final reader.

In `@internal/agent/workflowx/parallel.go`:
- Around line 185-204: Remove the unused nodeKey parameter from
runParallelInvoke and runParallelFanout, and stop forwarding it between them;
also update the AddParallelNode call site in
internal/agent/workflowx/parallel.go (Line 155) to omit key. In
internal/agent/workflowx/parallel_test.go (Line 218, Line 268, and Line 367),
remove the "par" argument from the affected helper calls. Do not add
compatibility wrappers or shims.

In `@internal/ingestion/pipeline/pipeline.go`:
- Around line 210-227: Remove the single-caller Pipeline.run helper and inline
its workflow invocation, cancellation handling, error wrapping, and
finalizeResult call directly into Run’s invocation loop, using Run’s existing
runCtx, current, compiled, and runState variables. Preserve the current return
values and error behavior while leaving finalizeResult unchanged.

In `@internal/service/agent_cancel_test.go`:
- Around line 64-90: Update
TestCancelSessionRunFinishedSessionDoesNotCreateCancelMarker to assert that
cancelling the persisted and missing sessions does not publish a session-scoped
canvas.CancelRequested marker, preserving the existing local active-entry
assertion; alternatively, rename the test to accurately describe only the local
active-session behavior it currently verifies.

In `@internal/service/agent_run_e2e_test.go`:
- Around line 23-24: Remove the unused collectEventTypes helper from the agent
run E2E test file, leaving the other checked helpers and failure-path tests
unchanged.

In `@internal/service/user.go`:
- Line 206: Define one exported default ParserIDs value, such as
entity.DefaultParserIDs, as the single source of truth and update
internal/service/user.go:206-206 to use it instead of the inline literal. Update
internal/admin/service.go:255-255 to use the same shared default, preserving the
consistent parser set including tag:Tag and the “Research Paper” label.
🪄 Autofix

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 Plus

Run ID: 087409ba-ec0d-4049-a3e6-991e97c832cc

📥 Commits

Reviewing files that changed from the base of the PR and between eada2f6 and 10bf817.

📒 Files selected for processing (52)
  • cmd/ragflow_server.go
  • internal/admin/service.go
  • internal/agent/canvas/checkpoint_store.go
  • internal/agent/canvas/checkpoint_store_test.go
  • internal/agent/canvas/compile.go
  • internal/agent/canvas/compile_test.go
  • internal/agent/canvas/interrupt_resume.go
  • internal/agent/canvas/interrupt_resume_test.go
  • internal/agent/canvas/node_body.go
  • internal/agent/canvas/run_tracker.go
  • internal/agent/canvas/run_tracker_test.go
  • internal/agent/canvas/runner.go
  • internal/agent/canvas/runner_cancel_test.go
  • internal/agent/canvas/state_serializer.go
  • internal/agent/canvas/state_serializer_test.go
  • internal/agent/component/fixture_stubs.go
  • internal/agent/dsl/testdata/resume.json
  • internal/agent/runtime/helpers.go
  • internal/agent/runtime/state.go
  • internal/agent/workflowx/loop.go
  • internal/agent/workflowx/loop_example_test.go
  • internal/agent/workflowx/loop_integration_test.go
  • internal/agent/workflowx/loop_options_test.go
  • internal/agent/workflowx/loop_test.go
  • internal/agent/workflowx/parallel.go
  • internal/agent/workflowx/parallel_helpers_test.go
  • internal/agent/workflowx/parallel_integration_test.go
  • internal/agent/workflowx/parallel_options_test.go
  • internal/agent/workflowx/parallel_test.go
  • internal/agent/workflowx/r3_interrupt_test.go
  • internal/common/parser_config.go
  • internal/entity/dataset.go
  • internal/handler/agent.go
  • internal/handler/agent_test.go
  • internal/handler/agent_wait_for_user_test.go
  • internal/ingestion/component/extractor.go
  • internal/ingestion/component/extractor_test.go
  • internal/ingestion/component/slice3_test.go
  • internal/ingestion/pipeline/builtin_registry_test.go
  • internal/ingestion/pipeline/pipeline.go
  • internal/ingestion/pipeline/pipeline_test.go
  • internal/ingestion/pipeline/template/ingestion_pipeline_resume.json
  • internal/ingestion/pipeline/template_integration_test.go
  • internal/ingestion/service/ingestion_service.go
  • internal/ingestion/task/pipeline_executor.go
  • internal/ingestion/task/pipeline_executor_defaults_test.go
  • internal/ingestion/task/task_context.go
  • internal/service/agent.go
  • internal/service/agent_cancel_test.go
  • internal/service/agent_run_e2e_test.go
  • internal/service/canvas_decode_test.go
  • internal/service/user.go
💤 Files with no reviewable changes (22)
  • internal/ingestion/pipeline/template/ingestion_pipeline_resume.json
  • internal/ingestion/pipeline/builtin_registry_test.go
  • internal/entity/dataset.go
  • internal/agent/canvas/checkpoint_store_test.go
  • internal/common/parser_config.go
  • internal/agent/canvas/checkpoint_store.go
  • internal/agent/canvas/run_tracker_test.go
  • internal/agent/canvas/state_serializer.go
  • internal/handler/agent_test.go
  • internal/ingestion/component/extractor_test.go
  • internal/ingestion/task/pipeline_executor.go
  • internal/agent/canvas/interrupt_resume_test.go
  • internal/agent/workflowx/parallel_helpers_test.go
  • internal/agent/dsl/testdata/resume.json
  • internal/agent/canvas/state_serializer_test.go
  • internal/agent/canvas/interrupt_resume.go
  • internal/agent/workflowx/r3_interrupt_test.go
  • internal/ingestion/pipeline/template_integration_test.go
  • internal/handler/agent_wait_for_user_test.go
  • internal/agent/canvas/compile_test.go
  • internal/ingestion/pipeline/pipeline_test.go
  • internal/agent/canvas/run_tracker.go

Comment on lines +28 to +36
// Run outcomes on a single Run() call:
//
// 1. Normal completion (runErr == nil): the buildRunFunc already
// emitted all workflow events (workflow_started, node_started,
// node_finished, message, message_end, workflow_finished) during
// execution. The Runner just sends the `done` terminator.
// 2. Eino interrupt (runErr is an *InterruptSignal or wrapped
// variant): emit `waiting_for_user` with the first interrupt
// id. Persist the id so the next call can resume via
// compose.ResumeWithData (signalled through root:
// __resume_interrupt_id__ + __resume_data__).
// 3. Cancel / timeout (errors.Is(err, context.Canceled) etc.):
// 2. Cancel / timeout (errors.Is(err, context.Canceled) etc.):
// silently close. The HTTP handler has already detached.
// 4. Other errors: emit `error` event with the err.Error() string.
// 3. Other errors: emit `error` event with the err.Error() string.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Correct the documented done terminator behavior.

Line 33 states that the Runner sends the done terminator on normal completion. The Run body does not push a done event. It only closes the channel, and the HTTP handler writes the done frame when it observes none. Align the doc with the current runtime path.

As per coding guidelines: "keep package and doc comments aligned with the current runtime path rather than migration history".

📝 Proposed doc fix
 //  1. Normal completion (runErr == nil): the buildRunFunc already
 //     emitted all workflow events (workflow_started, node_started,
 //     node_finished, message, message_end, workflow_finished) during
-//     execution. The Runner just sends the `done` terminator.
+//     execution. The Runner then closes the event channel; the HTTP
+//     handler writes the `done` terminator.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Run outcomes on a single Run() call:
//
// 1. Normal completion (runErr == nil): the buildRunFunc already
// emitted all workflow events (workflow_started, node_started,
// node_finished, message, message_end, workflow_finished) during
// execution. The Runner just sends the `done` terminator.
// 2. Eino interrupt (runErr is an *InterruptSignal or wrapped
// variant): emit `waiting_for_user` with the first interrupt
// id. Persist the id so the next call can resume via
// compose.ResumeWithData (signalled through root:
// __resume_interrupt_id__ + __resume_data__).
// 3. Cancel / timeout (errors.Is(err, context.Canceled) etc.):
// 2. Cancel / timeout (errors.Is(err, context.Canceled) etc.):
// silently close. The HTTP handler has already detached.
// 4. Other errors: emit `error` event with the err.Error() string.
// 3. Other errors: emit `error` event with the err.Error() string.
// Run outcomes on a single Run() call:
//
// 1. Normal completion (runErr == nil): the buildRunFunc already
// emitted all workflow events (workflow_started, node_started,
// node_finished, message, message_end, workflow_finished) during
// execution. The Runner then closes the event channel; the HTTP
// handler writes the `done` terminator.
// 2. Cancel / timeout (errors.Is(err, context.Canceled) etc.):
// silently close. The HTTP handler has already detached.
// 3. Other errors: emit `error` event with the err.Error() string.
🤖 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/agent/canvas/runner.go` around lines 28 - 36, Update the
normal-completion documentation near Run to state that Runner closes the channel
after buildRunFunc completes, while the HTTP handler emits the done frame when
it observes channel closure; do not claim that Runner sends the done terminator
directly. Keep the cancellation and error outcome descriptions unchanged.

Source: Coding guidelines

Comment on lines +133 to +140
// MarshalJSON serialises the CanvasState into the stable wire shape
// (canvasStateJSON). The struct contains a sync.RWMutex (unexported)
// and an atomic.Bool (indirected; serialises as 8 bytes without
// explicit handling), so the explicit hook defines the JSON form.
//
// Concurrency: the lock is held briefly while we snapshot the maps;
// readers may briefly block during marshal, which is fine for the
// checkpoint/serializer hot path. The lock is read-only so concurrent
// SetVar calls also proceed.
// readers may briefly block during marshal. The lock is read-only so
// concurrent SetVar calls also proceed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -eu

file="internal/agent/runtime/state.go"
printf '%s\n' '--- target file outline ---'
ast-grep outline "$file" --match 'MarshalJSON' --view expanded || true
printf '%s\n' '--- target implementation ---'
nl -ba "$file" | sed -n '1,220p'
printf '%s\n' '--- related symbols and callers ---'
rg -n -C 3 'SafeJSONMarshal|MarshalJSON|UnmarshalJSON|SetVar|type CanvasState' internal/agent/runtime

Repository: infiniflow/ragflow

Length of output: 13846


🏁 Script executed:

#!/bin/bash
set -eu

printf '%s\n' '--- CanvasState and JSON methods ---'
sed -n '50,190p' internal/agent/runtime/state.go
printf '%s\n' '--- SafeJSONMarshal implementation ---'
sed -n '1,180p' internal/agent/runtime/json_safe.go
printf '%s\n' '--- relevant type declarations and field assignments ---'
sed -n '1,55p' internal/agent/runtime/state.go

Repository: infiniflow/ragflow

Length of output: 12254


🏁 Script executed:

#!/bin/bash
set -eu

printf '%s\n' '--- standalone atomic.Bool JSON probe ---'
if command -v go >/dev/null 2>&1; then
  tmpdir="$(mktemp -d)"
  trap 'rm -rf "$tmpdir"' EXIT
  cat >"$tmpdir/main.go" <<'GO'
package main

import (
	"encoding/json"
	"fmt"
	"sync/atomic"
)

func main() {
	var b atomic.Bool
	raw, err := json.Marshal(b)
	if err != nil {
		panic(err)
	}
	fmt.Printf("atomic.Bool=%s\n", raw)

	type wrapped struct {
		Flag atomic.Bool `json:"flag"`
	}
	raw, err = json.Marshal(wrapped{Flag: b})
	if err != nil {
		panic(err)
	}
	fmt.Printf("wrapped=%s\n", raw)
}
GO
  (cd "$tmpdir" && go run main.go)
else
  printf '%s\n' 'go compiler unavailable; using source-level checks only'
fi

printf '%s\n' '--- lock and serializer call order ---'
python3 - <<'PY'
from pathlib import Path

p = Path("internal/agent/runtime/state.go").read_text()
start = p.index("func (s *CanvasState) MarshalJSON()")
end = p.index("\n}\n\n// UnmarshalJSON", start) + 2
body = p[start:end]
print("RLock before SafeJSONMarshal:", body.index("s.mu.RLock()") < body.index("SafeJSONMarshal(snap)"))
print("RUnlock deferred before SafeJSONMarshal:", body.index("defer s.mu.RUnlock()") < body.index("SafeJSONMarshal(snap)"))
print("SafeJSONMarshal is final return:", "return SafeJSONMarshal(snap)" in body)
PY

printf '%s\n' '--- cleanForJSON copy behavior ---'
python3 - <<'PY'
from pathlib import Path

p = Path("internal/agent/runtime/json_safe.go").read_text()
checks = {
    "map[string]any allocates output map": "out := make(map[string]any, len(m))" in p,
    "map[string]map[string]any allocates output map": "out := make(map[string]map[string]any, len(val))" in p,
    "[]map[string]any allocates output slice": "out := make([]any, len(val))" in p,
    "generic slices allocate output slice": "cleaned := make([]any, length)" in p,
    "SafeJSONMarshal cleans before json.Marshal": "cleaned := cleanForJSON(v)" in p and "return json.Marshal(cleaned)" in p,
}
for name, result in checks.items():
    print(f"{name}: {result}")
PY

Repository: infiniflow/ragflow

Length of output: 659


Correct the MarshalJSON documentation.

MarshalJSON holds RLock through SafeJSONMarshal, so other readers may proceed but writers such as SetVar block. snap initially references the existing maps and slices, but SafeJSONMarshal copies and cleans them before encoding. atomic.Bool encodes as {}, not as 8 bytes.

🤖 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/agent/runtime/state.go` around lines 133 - 140, Correct the
documentation for MarshalJSON to state that RLock is held through
SafeJSONMarshal, allowing readers but blocking writers such as SetVar; clarify
that snap initially references existing maps and slices before SafeJSONMarshal
copies and cleans them, and that atomic.Bool serializes as {} rather than 8
bytes.

Sources: Coding guidelines, MCP tools

Comment on lines +213 to +214
// run executes a single Invoke of the compiled workflow, records progress via
// the sink, and returns the merged output.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Correct the helper doc comment.

run does not record progress. Run reports the component total through p.sink, and the framework callback records per-component events. If you keep the helper, describe only the Invoke and merge behavior.

🤖 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/ingestion/pipeline/pipeline.go` around lines 213 - 214, Update the
doc comment for the run helper to remove the claim that it records progress via
the sink. Describe only that it invokes the compiled workflow once and returns
the merged output, leaving progress reporting to Run and the framework callback.

Comment on lines +270 to +271
// TestNewAgentService_ConstructsPins that the constructor produces a
// usable service (no panic on field init).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Fix the doc comment typo.

The comment reads TestNewAgentService_ConstructsPins that the constructor.... A space is missing between the test name and pins.

📝 Proposed fix
-// TestNewAgentService_ConstructsPins that the constructor produces a
-// usable service (no panic on field init).
+// TestNewAgentService_Constructs pins that the constructor produces a
+// usable service (no panic on field init).
🤖 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/service/canvas_decode_test.go` around lines 270 - 271, Correct the
doc comment for TestNewAgentService_ConstructsPins by inserting the missing
space so it reads naturally as a description of the test constructing pins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant