7.9 KiB
AGENTS.md
Guidance for AI agents working in this repository.
Higress is a cloud-native API gateway built on Istio and Envoy. The control
plane extends Istio/pilot (Go); the data plane is Envoy extended with WASM
plugins (Go/Rust/C++/AssemblyScript) and a Go-based golang-filter. It supports
Ingress/Gateway API and ships a rich plugin ecosystem (including AI gateway
plugins).
Repository layout
Top-level directories (all paths relative to repo root):
cmd/higress/— main entrypoint (main.go) for the Higress controller binary.pkg/— core Go control-plane packages:bootstrap/,cert/,cmd/,common/,config/,ingress/(Ingress/Gateway config translation),kube/.api/— protobuf/CRD API definitions; Higress CRDs live inapi/extensions/v1alpha1(e.g. theWasmPlugintype). Generated withmake gen-api/make gen-client(seeapi/gen.sh,buf.*).client/— generated Go clientset for Higress CRDs.istio/— git submodules of higress-group forks of Istio (api,istio,client-go,pkg,proxy); see.gitmodules. Pulled viamake submodule(part ofprebuild).envoy/— Envoy +go-control-planesubmodules (higress-group forks).external/— vendored/external mirror dirs used during build (istio, envoy, proxy, etc.).plugins/— all data-plane plugins (see "Plugins" below).registry/— service-discovery registry integrations (nacos, consul, eureka, zookeeper, direct, mcp, ...).hgctl/— thehgctlCLI (separate Go module) for managing Higress.helm/— Helm charts:helm/core(the dev/install chart) andhelm/higress.test/—test/e2e/(conformance/e2e, see "Build & test") andtest/gateway/.tools/— build/CI scripting:tools/hack/(build scripts),tools/bin/,tools/linter/,*.mk.samples/— example manifests (gateway-api, hello-world, wasmplugin, ...).docker/,docs/,release-notes/— packaging, docs, and release notes.Makefile— istio common-files wrapper (supportsBUILD_WITH_CONTAINER); real targets live inMakefile.core.mk(+Makefile.overrides.mk).
Plugins
All plugins live under plugins/. See plugins/README.md for the contributor
overview. Prebuilt plugin images are published to
higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins.
plugins/wasm-go/ (primary WASM plugin framework, Go)
extensions/<name>/— one directory per plugin (~59 plugins, manyai-*). Each plugin is its own Go module:main.go,go.mod/go.sum,VERSION,README.md(+README_EN.md), oftenconfig/,util/,main_test.go. Optional.buildrcsetsEXTRA_TAGS; optionalprepare.sh/prepare.sh.plugin.wasmis a build artifact and is not committed.- Shared SDK: plugins depend on external modules
github.com/higress-group/wasm-goandgithub.com/higress-group/proxy-wasm-go-sdk(NOT an in-repo SDK dir). In-repo,plugins/wasm-go/pkg/mcp/provides MCP helpers andplugins/wasm-go/mcp-servers/holds MCP server plugins. examples/— minimal reference plugins (custom-log, custom-span-attribute, test-foreign-function).- Build:
plugins/wasm-go/Makefile.PLUGIN_NAME=<name> make buildbuilds a wasm file (output toextensions/<name>/plugin.wasm) + image viaDockerfile/DockerfileBuilder(uses awasm-go-builderimage, Go 1.24, TinyGo optional).make build-pushpushes the image;make local-buildbuilds locally withGOOS=wasip1 GOARCH=wasm go build -buildmode=c-shared. - Conventions:
VERSIONis the image tag; the CI/e2e batch builder (tools/hack/build-wasm-plugins.sh) only compiles a wasm-go plugin whoseVERSIONends in-alpha(see the section at the bottom of this file).
plugins/wasm-rust/ (Rust WASM plugins)
- Workspace-style: root
Cargo.toml/Cargo.lock, sharedsrc/,extensions/<name>/per plugin (e.g.ai-data-masking,ai-intent,request-block,say-hello,demo-wasm),example/. - Build via
plugins/wasm-rust/Makefile(PLUGIN_NAME=<name> make build, pluslint/test); the batch builder runs it whenPLUGIN_TYPE=RUST.
plugins/wasm-cpp/ (C++ WASM plugins, Bazel)
- Bazel project:
WORKSPACE,BUILD,bazel/,common/,scripts/,extensions/<name>/(e.g.basic_auth,jwt_auth,key_rate_limit,model_router, ...). Build viaplugins/wasm-cpp/Makefile(PLUGIN_NAME=<name> make build), invoked withPLUGIN_TYPE=CPP.
plugins/wasm-assemblyscript/ (AssemblyScript WASM plugins)
- Node/AssemblyScript project:
asconfig.json,package.json,assembly/,extensions/.
plugins/golang-filter/ (Envoy Go HTTP filter, NOT WASM)
- A native Envoy Golang HTTP filter (
main.go,mcp-server/,mcp-session/); compiled as a shared object (.so) independent of Envoy — no Envoy rebuild needed. Requires Higress >= 2.1.0. Plugins register inmain.go'sinit()viaRegisterHttpFilterFactoryAndConfigParser. Seeplugins/golang-filter/README.md. - Build:
plugins/golang-filter/Makefile(docker build, outputsgolang-filter_<arch>.so). Wired into the gateway image build viaMakefile.core.mktargetsbuild-golang-filter[-amd64|-arm64].
How plugins are loaded
WasmPlugin CRDs (extensions.higress.io/v1alpha1) reference a plugin by
url: — either oci://.../plugins/<name>:<version> (image) or
file:///opt/plugins/.../plugin.wasm (local mount used in e2e). The dev install
make install-dev-wasmplugin sets Helm global.volumeWasmPlugins=true to mount
locally built wasm files into the gateway.
Build & test
Run targets from the repo root; Makefile delegates to Makefile.core.mk.
Common ones:
make build/make build-linux— build the Higress controller binary (prebuildfirst fetches submodules).make build-hgctl— build thehgctlCLI.make build-gateway/make build-istio/make build-envoy— data-plane and control-plane images (gateway pulls in the golang-filter).make build-wasmplugins— runstools/hack/build-wasm-plugins.shto batch build WASM plugins (respectsPLUGIN_TYPE/PLUGIN_NAME; Go plugins require a-alphaVERSION).make gen-api/make gen-client— regenerate API/client code.
Conformance / e2e tests (test/e2e/)
- Entrypoint
test/e2e/e2e_test.go, run with build tagconformanceand--test-area/--execute-testsflags. - Cases live in
test/e2e/conformance/tests/as paired<name>.go+<name>.yamlfiles (~68 cases; WASM cases are prefixed by language, e.g.go-wasm-*,cpp-wasm-*). Support code:conformance/base/,conformance/utils/,conformance/embed.go. - Key Make targets (each spins up a kind cluster):
make higress-conformance-test— Ingress/Gateway conformance.make higress-wasmplugin-test— WASM plugin e2e (usesinstall-dev-wasmplugin, which builds plugins and mounts them).*-prepare/*-skip-docker-build/*-cleanvariants exist for iterating;run-higress-e2e-test[-wasmplugin]runsgo testagainst an already-prepared cluster (filter withTEST_SHORTNAME).
- For the specifics of authoring a wasm-go e2e test, see the section below.
Writing e2e conformance tests with wasm-go plugins
When adding an e2e conformance test that ships its own wasm-go plugin under
plugins/wasm-go/extensions/<name>/:
- The plugin's
VERSIONfile must end in-alpha(e.g.1.0.0-alpha). CI'stools/hack/build-wasm-plugins.shonly compiles a wasm-go plugin when its version ends in-alpha; otherwise it silently skips it. plugin.wasmis a build artifact and is not committed. If the plugin isn't built, thefile:///opt/plugins/.../plugin.wasmURL in the test'sWasmPluginmanifest resolves to a missing file, envoy rejects the wasm config and fails closed, and every request on that route returns HTTP 500. Locally this can be masked because a previously builtplugin.wasmstill exists on disk — so a test can pass locally yet 500 in CI.