RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
chore(deps): depend on org mirror infiniflow/onnxruntime_go (#19169)
xugangqiang4298700cb269
diff --git a/.github/workflows/sep-tests.yml b/.github/workflows/sep-tests.ymlindex 837ee36f7b..28b16885bf 100644--- a/.github/workflows/sep-tests.yml+++ b/.github/workflows/sep-tests.yml@@ -30,6 +30,14 @@ concurrency:group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}${{ github.event.action == 'labeled' && github.event.label.name != 'ci' && format('-ignore-{0}', github.run_id) || '' }}cancel-in-progress: true+# infiniflow/onnxruntime_go is a fresh org mirror that is not yet present in the+# public Go checksum database / proxy. Mark it private so Go skips the proxy and+# sumdb for this path and resolves it directly from GitHub (Go's default+# GOPROXY keeps the ",direct" fallback). Required for the in-process DeepDoc+# backend to build against github.com/infiniflow/onnxruntime_go.+env:+ GOPRIVATE: github.com/infiniflow/onnxruntime_go+jobs:ragflow_preflight:name: ragflow_preflightdiff --git a/build.sh b/build.shindex 888c8eb365..2a1c8f5ae9 100755--- a/build.sh+++ b/build.sh@@ -402,12 +402,12 @@ build_go() {[ -n "$STRIP_SYMBOLS" ] && strip_flags=(-ldflags="-s -w")echo "Building RAGFlow binary: $RAGFLOW_CLI_BINARY and $RAGFLOW_SERVER_BINARY"- GOPROXY=${GOPROXY:-https://goproxy.cn,https://proxy.golang.org,direct} \- go build "${strip_flags[@]}" -o "$RAGFLOW_CLI_BINARY" cmd/ragflow-cli.go+ GOPROXY=${GOPROXY:-https://goproxy.cn,https://proxy.golang.org,direct} CGO_ENABLED=1 \+ go build -tags cgo,static "${strip_flags[@]}" -o "$RAGFLOW_CLI_BINARY" cmd/ragflow-cli.goGOPROXY=${GOPROXY:-https://goproxy.cn,https://proxy.golang.org,direct} CGO_ENABLED=1 \CGO_CFLAGS="$CGO_CFLAGS" CGO_LDFLAGS="$CGO_LDFLAGS" \- go build -tags cgo "${strip_flags[@]}" -o "$RAGFLOW_SERVER_BINARY" \+ go build -tags cgo,static "${strip_flags[@]}" -o "$RAGFLOW_SERVER_BINARY" \cmd/ragflow_server.go@@ -513,8 +513,8 @@ setup_cgo_env() {return 1;;esac- # Statically link libonnxruntime*.a into the binary. The forked Go binding- # (onnxruntime_go, github.com/xugangqiang/onnxruntime_go) resolves+ # Statically link libonnxruntime*.a into the binary. The org Go binding+ # (onnxruntime_go, github.com/infiniflow/onnxruntime_go) resolves# OrtGetApiBase with dlopen(NULL), so the symbols must (a) be pulled in# wholesale with --whole-archive (ORT registers its execution providers# lazily at runtime, beyond what a normal link would keep) and (b) be@@ -604,7 +604,7 @@ run_go_tests() {fiGOPROXY=${GOPROXY:-https://goproxy.cn,https://proxy.golang.org,direct} CGO_ENABLED=1 \CGO_CFLAGS="$CGO_CFLAGS" CGO_LDFLAGS="$CGO_LDFLAGS" \- go test -count=1 "$@"+ go test -tags cgo,static -count=1 "$@"run_native_tests}@@ -622,7 +622,7 @@ run_native_tests() {( cd "$PROJECT_ROOT" && \GOPROXY=${GOPROXY:-https://goproxy.cn,https://proxy.golang.org,direct} \CGO_ENABLED=1 \- go test -tags cgo -count=1 ./internal/deepdoc/native/... )+ go test -tags cgo,static -count=1 ./internal/deepdoc/native/... )}# Run the model-backed integration tests of the native package and the@@ -651,20 +651,20 @@ run_native_integration_tests() {( cd "$PROJECT_ROOT" && \GOPROXY=${GOPROXY:-https://goproxy.cn,https://proxy.golang.org,direct} \CGO_ENABLED=1 \- go test -tags "cgo integration fetch_testdata" -count=1 ./internal/deepdoc/native/... )+ go test -tags "cgo static integration fetch_testdata" -count=1 ./internal/deepdoc/native/... )print_section "Running native integration concurrency tests (race detector on)"( cd "$PROJECT_ROOT" && \GOPROXY=${GOPROXY:-https://goproxy.cn,https://proxy.golang.org,direct} \CGO_ENABLED=1 \- go test -tags "cgo integration fetch_testdata" -race -count=1 \+ go test -tags "cgo static integration fetch_testdata" -race -count=1 \-run 'TestInferenceConcurrency' ./internal/deepdoc/native/... )print_section "Running native_analyzer race tests (race detector on)"( cd "$PROJECT_ROOT" && \GOPROXY=${GOPROXY:-https://goproxy.cn,https://proxy.golang.org,direct} \CGO_ENABLED=1 \- go test -tags "cgo integration fetch_testdata" -race -count=1 \+ go test -tags "cgo static integration fetch_testdata" -race -count=1 \./internal/deepdoc/parser/pdf/inference/native_analyzer/... )}@@ -683,7 +683,7 @@ run_go_tests_tagged() {fiGOPROXY=${GOPROXY:-https://goproxy.cn,https://proxy.golang.org,direct} CGO_ENABLED=1 \CGO_CFLAGS="$CGO_CFLAGS" CGO_LDFLAGS="$CGO_LDFLAGS" \- go test -tags "${tags}" -count=1 "$@"+ go test -tags "${tags} static" -count=1 "$@"}# Clean build artifactsdiff --git a/cmd/ragflow_server.go b/cmd/ragflow_server.goindex 9274be2306..b3f2071090 100644--- a/cmd/ragflow_server.go+++ b/cmd/ragflow_server.go@@ -1084,7 +1084,8 @@ func configureTTSSynthesizer(modelProviderService *service.ModelProviderService)// registerNativeDeepDoc wires the in-process (Go) DeepDoc backend as the local// inference backend. The server is built with -tags cgo and links ONNX Runtime// statically (libonnxruntime.a, resolved at runtime via dlopen(NULL) from the-// running binary — see the onnxruntime_go fork), so there is no external+// running binary — see github.com/infiniflow/onnxruntime_go, the org mirror of+// yalue/onnxruntime_go), so there is no external// DeepDoc HTTP service and no dynamic .so deployment.//// Fail-fast contract (P0): the in-process backend must be available at startupdiff --git a/go.mod b/go.modindex df3ade4dec..f53f75c095 100644--- a/go.mod+++ b/go.mod@@ -227,7 +227,7 @@ require (github.com/wk8/go-ordered-map/v2 v2.1.8 // indirectgithub.com/xuri/efp v0.0.1 // indirectgithub.com/xuri/nfp v0.0.2-0.20250530014748-2ddeb826f9a9 // indirect- github.com/yalue/onnxruntime_go v1.23.0+ github.com/infiniflow/onnxruntime_go v1.23.1github.com/yargevad/filepathx v1.0.0 // indirectgithub.com/yuin/gopher-lua v1.1.1 // indirectgo.mongodb.org/mongo-driver/v2 v2.6.0 // indirect@@ -259,8 +259,10 @@ replace github.com/infiniflow/infinity-go-sdk => github.com/infiniflow/infinity/replace github.com/AkmalOt/gomsg => github.com/xugangqiang/gomsg v0.0.0-20260407083308-985c3a1a76b7-// onnxruntime_go is forked to github.com/xugangqiang/onnxruntime_go (static-only:-// resolves OrtGetApiBase via dlopen(NULL), no .so fallback). The fork is published at-// that remote with tag v1.23.0; we pin a remote replace matching the gomsg pattern above-// so the vendored tree no longer needs to live in-tree.-replace github.com/yalue/onnxruntime_go => github.com/xugangqiang/onnxruntime_go v1.23.0+// onnxruntime_go is mirrored to github.com/infiniflow/onnxruntime_go (org-owned+// fork of yalue/onnxruntime_go at v1.23.0) so the in-process DeepDoc backend no+// longer depends on a personal fork or the upstream repo directly. ONNX Runtime is+// linked statically (--whole-archive + --export-dynamic); OrtGetApiBase is then+// resolved at runtime via dlopen(NULL) from the running binary, so no+// libonnxruntime.so is required. The module path matches the import path, so no+// replace directive is needed.diff --git a/go.sum b/go.sumindex ff19b7b53f..47f2d565a2 100644--- a/go.sum+++ b/go.sum@@ -343,6 +343,10 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4Tgithub.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=github.com/infiniflow/infinity/go v0.0.0-20260806040857-d755c5ad25d9 h1:mqPwCOTktwl0V1f3tkfCRFonGQ3XrQ43gvH+TOWec6o=github.com/infiniflow/infinity/go v0.0.0-20260806040857-d755c5ad25d9/go.mod h1:hw3z5AwNFsGy1cdrE0Mfjot2y9jqVHTxBufUx9VzZ+0=+github.com/infiniflow/onnxruntime_go v1.23.0 h1:cUhSkGOyMAF7v0mOm97/V4hUhIVi5apJMm6WqKrSTwc=+github.com/infiniflow/onnxruntime_go v1.23.0/go.mod h1:dFFL0KdgeeEDXoE9cjrg/ipQg0wEvD0tkGIg2UH0jdE=+github.com/infiniflow/onnxruntime_go v1.23.1 h1:PvhtCkWAmnMwy16QrkohkBKUOH/EOrEZm0LO/QykIo0=+github.com/infiniflow/onnxruntime_go v1.23.1/go.mod h1:dFFL0KdgeeEDXoE9cjrg/ipQg0wEvD0tkGIg2UH0jdE=github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=@@ -574,8 +578,6 @@ github.com/x-cray/logrus-prefixed-formatter v0.5.2 h1:00txxvfBM9muc0jiLIEAkAcIMJgithub.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE=github.com/xugangqiang/gomsg v0.0.0-20260407083308-985c3a1a76b7 h1:iX9RUmlLw+Hoe78WV5vlm+JjIZUCzdRn2y6tWNxZTeY=github.com/xugangqiang/gomsg v0.0.0-20260407083308-985c3a1a76b7/go.mod h1:TCjWm+lo7de/zYHb8rHfVSaKxOP4tZNrnRUzkqV4r28=-github.com/xugangqiang/onnxruntime_go v1.23.0 h1:Oo//W+NHBkDwjjyOa9US8G9ryae5cVRbAMgXR6wxohw=-github.com/xugangqiang/onnxruntime_go v1.23.0/go.mod h1:b4X26A8pekNb1ACJ58wAXgNKeUCGEAQ9dmACut9Sm/4=github.com/xuri/efp v0.0.1 h1:fws5Rv3myXyYni8uwj2qKjVaRP30PdjeYe2Y6FDsCL8=github.com/xuri/efp v0.0.1/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=github.com/xuri/excelize/v2 v2.11.0 h1:HxaEFl6sRN2+8J5a8HaKq+0M4FsjBGMnWWtjOCPSG88=diff --git a/internal/common/environments.go b/internal/common/environments.goindex f461377289..910565fc84 100644--- a/internal/common/environments.go+++ b/internal/common/environments.go@@ -259,8 +259,8 @@ func HasModelFiles(dir string) bool {// ORT_VERSION in ragflow_deps/download_go_deps.py and ragflow_deps/download_deps.py)// — NOT a single source of truth. The download URL and extracted dir name are// built from those ORT_VERSION constants, not from this one. The Go binding-// (github.com/yalue/onnxruntime_go, forked to-// github.com/xugangqiang/onnxruntime_go) and the pip onnxruntime== pin must+// (github.com/infiniflow/onnxruntime_go, the org mirror of yalue/onnxruntime_go)+// and the pip onnxruntime== pin must// track this MINOR version: the binding uses its own release numbering// (v1.23.0 <-> ORT 1.23.x) but is ABI-compatible with this native release on// the same minor line. ONNX Runtime is linked statically (libonnxruntime.a),diff --git a/internal/deepdoc/native/ocr_rec.go b/internal/deepdoc/native/ocr_rec.goindex e1e0b16c58..a4532a1ae6 100644--- a/internal/deepdoc/native/ocr_rec.go+++ b/internal/deepdoc/native/ocr_rec.go@@ -18,7 +18,7 @@ import ("strings""sync"- ort "github.com/yalue/onnxruntime_go"+ ort "github.com/infiniflow/onnxruntime_go")const (diff --git a/internal/deepdoc/native/session.go b/internal/deepdoc/native/session.goindex 397d48b766..99914e8863 100644--- a/internal/deepdoc/native/session.go+++ b/internal/deepdoc/native/session.go@@ -19,7 +19,7 @@ import ("fmt""sync"- ort "github.com/yalue/onnxruntime_go"+ ort "github.com/infiniflow/onnxruntime_go")var (@@ -36,15 +36,17 @@ var (// call multiple times; only the first takes effect. Call it once at process// start (the CLI does this from main).//-// This fork links ONNX Runtime statically (libonnxruntime.a is linked into the-// binary with --whole-archive and exported via -Wl,--export-dynamic; see-// build.sh: ONNX_RUNTIME_STATIC_DIR). The forked onnxruntime_go binding-// resolves OrtGetApiBase from the running binary itself via dlopen(NULL) (the+// The in-process DeepDoc backend links ONNX Runtime statically (libonnxruntime.a+// is linked into the binary with --whole-archive and exported via+// -Wl,--export-dynamic; see build.sh: ONNX_RUNTIME_STATIC_DIR). The org+// onnxruntime_go binding (github.com/infiniflow/onnxruntime_go) resolves+// OrtGetApiBase from the running binary itself via dlopen(NULL) (the// process-global symbol table), so no external libonnxruntime.so is needed and// there is no dynamic .so deployment. A main executable CANNOT be dlopen'd by// its own file path (glibc refuses), which is exactly why the binding uses the-// NULL handle instead of a path. InitORT therefore takes no library path; the-// fork's SetSharedLibraryPath is a retained no-op.+// NULL handle instead of a path. InitORT therefore takes no library path;+// ragflow never calls SetSharedLibraryPath, so the binding resolves ORT from the+// running binary via dlopen(NULL).func InitORT() error {ortOnce.Do(func() {ortInitErr = ort.InitializeEnvironment()diff --git a/internal/development.md b/internal/development.mdindex a0226c2146..210d6f751b 100644--- a/internal/development.md+++ b/internal/development.md@@ -84,7 +84,8 @@ uv run python3 ragflow_deps/download_deps.py> **ONNX Runtime is mandatory for the production binary.** The in-process (Go)> DeepDoc backend is statically linked against `libonnxruntime.a` via> `--whole-archive -Wl,--export-dynamic`, and `OrtGetApiBase` is resolved at-> runtime through `dlopen(NULL)`. The forked `onnxruntime_go` binding only+> runtime through `dlopen(NULL)`. The org `onnxruntime_go` binding+> (github.com/infiniflow/onnxruntime_go, the mirror of yalue/onnxruntime_go) only> needs `-ldl` to *compile*, so a binary built **without** ORT links> successfully but dies at startup with:> `Error looking up OrtGetApiBase in statically-linked ONNX Runtime` → fatal