This guide is intended for developers who need to modify the TNG source code or debug/run tests locally. It introduces the project structure, how to build TNG and its images, how to run the test suites, and how releases are made.
- tng/: Core service implementation, including command-line entry, configuration parsing, tunnel (Ingress/Egress), remote attestation, observability, and other main logic.
- tng/src/tunnel/provider/: Pluggable remote-attestation provider layer (evidence, token, attester, converter, and verifier wiring) to support multiple providers for attestation-agent and attestation-service, such as CoCo and Intel Trust Authority (ITA).
- rats-cert/: Remote attestation library used by
tng: evidence collection and verification for the CoCo and ITA providers, the in-process attestation service (coco-builtin-as-*features), and fetching signed policies. - tng-testsuite/: Integration test suite, providing orchestratable "scenario tasks" covering typical usage such as HTTP proxy, transparent proxy, Socks5, OHTTP, and unidirectional/bidirectional remote attestation.
- tng-wasm/: Browser-side JavaScript SDK, providing interfaces like
tng_fetch, used in conjunction with OHTTP and remote attestation. For specific usage, seetng-wasm/README.md. - cohere/docker/: The Dockerfile for the published container images, plus the default configuration and entrypoints of the ingress and egress images.
- cohere/python/cohere-tng/: The
cohere-tngPython package, anhttpxtransport built as a native Rust extension with PyO3 and maturin. - cohere/python/conseel/: The
conseelPython package, a drop-in encrypted transport for AI SDKs built oncohere-tng. - docs/: User and development documentation, including the configuration manual (
configuration.md) and this developer guide.
If you only want to compile and run TNG locally, you can focus on the tng/ directory. If you need to debug a complete end-to-end scenario (e.g., "HTTP proxy + unidirectional remote attestation"), it is recommended to prioritize running the corresponding tng-testsuite case for reproduction.
This project requires two versions of the Rust toolchain:
1.95.0: The toolchain used to build TNG from source. It is pinned in rust-toolchain.toml, sorustupselects it automatically inside the repository.nightly-2025-07-07: The toolchain required for building the TNG JavaScript SDK. For details, see tng-wasm/README.md.
- Clone the source code:
git clone https://github.com/cohere-ai/TNG.git
cd TNGThe default branch is cohere. Release tags are named vX.Y.Z.
-
Install rustup. The first
cargocommand run in the repository installs the toolchain fromrust-toolchain.toml. -
Install the build dependencies. On Ubuntu, at minimum:
sudo apt-get install -y build-essential protobuf-compiler libprotobuf-dev libssl-dev pkg-config clangprotoc is required: rats-cert generates gRPC code at build time. The test-runner image, .github/test-deps/Dockerfile.test-runner, carries the full set of dependencies used in CI, including the network tools the integration tests use (iptables, iproute2, ipset, socat and others).
- Build TNG:
make bin-build # RUSTFLAGS="--cfg tokio_unstable" cargo build --releaseThe binary is written to target/release/tng.
The in-process attestation service (as_provider: coco_builtin) is not built by default. Enable it with one or more of the coco-builtin-as-* features in tng/Cargo.toml, for example --features tng/coco-builtin-as-tdx. Some of them need extra system libraries; cohere/docker/Dockerfile lists them.
CI runs these on every pull request (co-clippy.yml and co-fmt.yml):
make clippy # cargo clippy --all-targets -- -D warnings
cargo fmt --checkTests run in CI through .github/workflows/co-test.yml, which creates a GCP c3-standard-8 Confidential VM with Intel TDX, starts the attestation services, and runs every suite inside the test-runner image. The steps below follow that workflow.
Important
Many tests collect real TDX evidence, so they must run on a TDX guest (/dev/tdx_guest must exist). The ITA tests also need an Intel Trust Authority API key in the ITA_API_KEY environment variable, and are skipped when it is not set.
In this repository, integration tests are mainly concentrated in the tng-testsuite crate, covering common scenarios through different test files, such as:
tcp_two_way_ra.rs: Verifies TCP scenarios where both the client and server have remote attestation enabled (mutual RA).http_encapulation_with_ingress_httpproxy.rs: Verifies encrypted HTTP scenarios where the client accesses via HTTP proxy and the server uses netfilter.python_sdk.rs: Verifies thecohere-tngPython SDK against a TNG egress.js_sdk_http.rs: Verifies scenarios using the browser-side JavaScript SDK (tng-wasm) with OHTTP and remote attestation.
The test dependencies are defined in .github/test-deps/docker-compose.yml:
- keygen: Generates the attestation service's token-signing certificate chain into
.github/test-deps/.keys/. - as: The CoCo attestation service (
restful-as), on port8081. - cert-proxy: Serves the token-signing certificate at
GET /certificateand forwards all other requests to the attestation service, on port8080. This is the attestation service address the tests use. - aa: The CoCo attestation agent, built for TDX. It listens on
/run/confidential-containers/attestation-agent/attestation-agent.sock. - asr: The CoCo API Server Rest (ASR), which proxies HTTP requests to the attestation agent, on
127.0.0.1:8006.
Start them and copy the certificates to the paths the tests read:
cd .github/test-deps
docker compose up -d --build --wait --wait-timeout 120
./setup_test_certs.sh # copies .keys/ to /tmp/as-full.pem and /tmp/as-ca.pem
curl -sf http://127.0.0.1:8080/certificate | head -c 200Note
The upstream ASR is missing two interface features needed by TNG: an encoding parameter on /aa/evidence for hex-encoded runtime data, and an /aa/additional_evidence endpoint for fetching additional evidence (for devices such as GPU). These are implemented in the Cohere fork (PR), which is what Dockerfile.asr installs.
Important
The ASR rejects any request whose source IP is not loopback (127.0.0.1), returning 403 Forbidden. The tests and the ASR must therefore run on the same host, which is why the asr service uses host networking.
docker build -t test-runner -f .github/test-deps/Dockerfile.test-runner .github/test-depsThe commands below run inside it, with the repository mounted at /workspace. Run them from the repository root:
docker run --rm -it --privileged --network host \
-e RUST_LOG=warn \
-e ITA_API_KEY \
-v "$PWD":/workspace \
-v /run/confidential-containers/attestation-agent:/run/confidential-containers/attestation-agent \
-v /tmp/as-full.pem:/tmp/as-full.pem:ro \
-v /tmp/as-ca.pem:/tmp/as-ca.pem:ro \
test-runner bashThe integration tests create network namespaces and iptables rules, so the container must be privileged and use host networking.
.github/test-skip-list.txt lists tests CI skips, one per line, each with a comment saying why. CI passes each entry to cargo test as --skip <name>. The commands below build these flags inline.
cargo test --workspace --bins --lib --features tng/coco-builtin-as-tdx -- --nocapture \
$(sed 's/#.*//' .github/test-skip-list.txt | xargs -n1 printf -- '--skip %s ')cargo test --no-default-features --features on-source-code --package tng-testsuite -- --nocapture \
$(sed 's/#.*//' .github/test-skip-list.txt | xargs -n1 printf -- '--skip %s ')To run a single scenario, add --test <name>, for example --test tcp_two_way_ra.
apt-get update && apt-get install -y --no-install-recommends python3-venv
python3 -m venv /workspace/.venv
/workspace/.venv/bin/pip install maturin httpx pytest
(cd cohere/python/cohere-tng && /workspace/.venv/bin/maturin develop)
/workspace/.venv/bin/pip install -e cohere/python/conseel
# Unit tests, no network needed
/workspace/.venv/bin/pytest cohere/python/cohere-tng/tests/ -v
# Integration tests against a TNG egress
cargo test --no-default-features --features on-source-code,python-sdk \
--package tng-testsuite --test python_sdk -- --nocaptureAll published images are built from cohere/docker/Dockerfile, with the repository root as the build context. Pick the image with --target:
| Target | Published as | Description |
|---|---|---|
tng |
ghcr.io/cohere-ai/tng |
Plain TNG with no baked-in configuration. |
ingress |
ghcr.io/cohere-ai/tng-ingress |
Pre-configured ingress. See cohere/docker/ingress/README.md. |
egress-ita |
ghcr.io/cohere-ai/tng-ita |
Pre-configured OHTTP egress using Intel Trust Authority. |
egress-trustee |
ghcr.io/cohere-ai/tng-trustee |
Pre-configured OHTTP egress for the background check model. |
docker build -f cohere/docker/Dockerfile --target tng -t tng:latest .
docker run -it --rm --privileged --network host --cgroupns=host tng:latest tng launch --config-content='<your config json string>'The in-process attestation service verifiers are controlled by the BUILTIN_AS_TDX, BUILTIN_AS_AZSNP and BUILTIN_AS_NVIDIA build arguments, all on by default. Each takes 1/true/yes/on or 0/false/no/off. Turning all three off builds TNG with no verifier code and none of their system libraries:
docker build -f cohere/docker/Dockerfile --target tng \
--build-arg BUILTIN_AS_TDX=0 --build-arg BUILTIN_AS_AZSNP=0 --build-arg BUILTIN_AS_NVIDIA=0 \
-t tng:minimal .The comments at the top of the Dockerfile explain each verifier's dependencies.
CI builds all four images on every push to cohere (co-build-docker.yml), tags them cohere and sha-<commit>, and attaches build provenance and SBOM attestations.
Releases are driven by the version in the workspace Cargo.toml:
- Run the Cohere Bump Version workflow (
co-bump-version.yml) manually. It computes the next version from the conventional commits since the last tag withgit-cliff, updatesCargo.tomlandCargo.lock, and pushes arelease/vX.Y.Zbranch. Open a pull request from that branch intocohere. - Merging the pull request changes
Cargo.tomloncohere, which triggers Cohere Auto Release Check (co-auto-release-check.yml). If the version has no tag yet, it dispatches Cohere Release (co-release.yml). co-release.ymlwaits for every other workflow on the commit to succeed, then:- publishes the
cohere-tngandconseelwheels thatco-build-python.ymlbuilt for that commit to PyPI, - tags the four images built for that commit with the version and
latest, - creates the
vX.Y.Ztag and GitHub release.
- publishes the
PyPI uploads cannot be undone. If a release job fails after publishing, use "Re-run failed jobs" on the same run rather than dispatching a new one.