Skip to content

docs(repo): add conformance rule for NX_* env var documentation#35353

Merged
barbados-clemens merged 13 commits into
masterfrom
cu/env-var-conformance-docs
Apr 22, 2026
Merged

docs(repo): add conformance rule for NX_* env var documentation#35353
barbados-clemens merged 13 commits into
masterfrom
cu/env-var-conformance-docs

Conversation

@barbados-clemens

@barbados-clemens barbados-clemens commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Current Behavior

NX_* env vars can be added to Nx source without being documented in astro-docs/src/content/docs/reference/environment-variables.mdoc. Nothing catches the drift.

Expected Behavior

Adds a conformance rule (env-vars-documented) that fails when an NX_* var is read in source but missing from the docs. Covers TS/JS process.env.NX_* and Rust env::var / env! patterns, skipping tests and fixtures. An ignore list in nx.json handles internal markers not meant to be documented.

Also documents the user-facing vars the first run surfaced (self-hosted cache, provenance, plugin isolation, Nx Cloud timeouts, etc.) and marks NX_CLOUD_AUTH_TOKEN and NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT as deprecated.

Related Issue(s)

N/A — internal tooling improvement.

@netlify

netlify Bot commented Apr 21, 2026

Copy link
Copy Markdown

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit d97c1b2
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69e907273d52180008764163
😎 Deploy Preview https://deploy-preview-35353--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Apr 21, 2026

Copy link
Copy Markdown

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit d97c1b2
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69e90727d7f0370008a442d3
😎 Deploy Preview https://deploy-preview-35353--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud

nx-cloud Bot commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit d97c1b2

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 42m 16s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 17s View ↗
nx build workspace-plugin ✅ Succeeded 4m 40s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 23s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 6s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-22 18:27:43 UTC

@barbados-clemens barbados-clemens changed the title chore(repo): add conformance rule for NX_* env var documentation docs(repo): add conformance rule for NX_* env var documentation Apr 21, 2026
@barbados-clemens barbados-clemens self-assigned this Apr 21, 2026
nx-cloud[bot]

This comment was marked as outdated.

@nx-cloud nx-cloud 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.

✅ The fix from Nx Cloud was applied automatically

We fixed the astro-docs:format failure by running Prettier on astro-docs/src/content/docs/reference/environment-variables.mdoc, which had style inconsistencies introduced by the PR's documentation additions. Our change brings the file into compliance with the workspace's Prettier formatting rules, which the format check enforces across all .mdoc files.

Tip

We verified this fix by re-running astro-docs:format.

Suggested Fix changes
diff --git a/astro-docs/src/content/docs/reference/environment-variables.mdoc b/astro-docs/src/content/docs/reference/environment-variables.mdoc
index c302b161ef..9dab00b318 100644
--- a/astro-docs/src/content/docs/reference/environment-variables.mdoc
+++ b/astro-docs/src/content/docs/reference/environment-variables.mdoc
@@ -63,7 +63,7 @@ The following environment variables are ones that you can set to change the beha
 | `NX_SKIP_PROVENANCE_CHECK`                 | boolean        | If set to `true`, skips `npm` provenance verification when installing packages during `nx migrate`. This is a security-sensitive check. Only disable it if you understand the implications.                                                                                                          |
 | `NX_NATIVE_LOGGING`                        | string         | Filter directive for the native (Rust) tracing logger. Defaults to `nx::native=info`. Set to a log level (`trace`, `debug`, `info`, `warn`, `error`, `off`) to control all native logs, or scope by crate or module (e.g. `nx=trace`, `nx::native::tasks::hashers=debug`, `[{project_name=myapp}]`). |
 | `NX_NATIVE_FILE_LOGGING`                   | string         | Enables the native (Rust) tracing logger and writes logs to `.nx/workspace-data/nx.log`. Accepts the same filter directives as `NX_NATIVE_LOGGING` (e.g. `debug`, `info`, `[{project_name=myapp}]`). Useful for debugging native code paths.                                                         |
-| `NX_REJECT_UNKNOWN_LOCAL_CACHE`            | boolean        | Legacy cache safety toggle. Set to `0` or `false` to allow reading a local cache that wasn't populated by the current machine. Not supported with the new database cache. See [legacy cache](/docs/reference/deprecated/legacy-cache#nxrejectunknownlocalcache).                                               |
+| `NX_REJECT_UNKNOWN_LOCAL_CACHE`            | boolean        | Legacy cache safety toggle. Set to `0` or `false` to allow reading a local cache that wasn't populated by the current machine. Not supported with the new database cache. See [legacy cache](/docs/reference/deprecated/legacy-cache#nxrejectunknownlocalcache).                                     |
 | `NX_SELF_HOSTED_REMOTE_CACHE_SERVER`       | string         | URL of a self-hosted remote cache server. When set, Nx uses this endpoint for remote cache reads and writes instead of Nx Cloud.                                                                                                                                                                     |
 | `NX_SELF_HOSTED_REMOTE_CACHE_ACCESS_TOKEN` | string         | Bearer token passed as the `Authorization` header when contacting the self-hosted remote cache server configured via `NX_SELF_HOSTED_REMOTE_CACHE_SERVER`.                                                                                                                                           |
 

🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.

Revert fix via Nx Cloud  

View interactive diff ↗

🎓 Learn more about Self-Healing CI on nx.dev

@barbados-clemens barbados-clemens force-pushed the cu/env-var-conformance-docs branch from 838b122 to 7edd9e5 Compare April 21, 2026 18:25
@barbados-clemens barbados-clemens marked this pull request as ready for review April 21, 2026 18:25
@barbados-clemens barbados-clemens requested a review from a team as a code owner April 21, 2026 18:25
Comment thread terminalOutput Outdated

@AgentEnder AgentEnder left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The rust bit is the only real change I'm requesting, the others are "we may want to doc this one" comments to open a discussion

Comment thread nx.json Outdated
Comment thread nx.json Outdated
Comment thread nx.json Outdated
Comment thread nx.json Outdated
Comment thread nx.json Outdated
Comment thread tools/workspace-plugin/src/conformance-rules/env-vars-documented/index.ts Outdated
@barbados-clemens barbados-clemens enabled auto-merge (squash) April 21, 2026 19:59
@Tobbe Tobbe mentioned this pull request Apr 22, 2026
4 tasks
barbados-clemens and others added 13 commits April 22, 2026 12:35
Adds `env-vars-documented` conformance rule that scans Nx source
for `NX_*` environment variable reads and fails when any are missing
from `astro-docs/.../environment-variables.mdoc`. Registers the rule
in `nx.json` with an initial ignore list for internal markers, and
documents previously-undocumented user-facing vars (including Nx
Cloud timeouts, self-hosted cache, provenance, and isolation flags).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…LOGGING

Extends the conformance rule's Rust patterns to catch
`EnvFilter::(try_)?from_env("NX_*")` usage from `tracing_subscriber`,
which was missed by the `env::var` / `env!` patterns. Documents
`NX_NATIVE_LOGGING` (filter directive for the native tracing logger).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The variable is still read by the Nx Cloud client, so label it as
typically not needed rather than deprecated and point users at
`--no-dte` / `--no-agents`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: barbados-clemens <barbados-clemens@users.noreply.github.com>
Co-authored-by: barbados-clemens <barbados-clemens@users.noreply.github.com>
Switch source file reads from `readFileSync` to the conformance
`tree.read` helper used by sibling rules (drops `workspaceRoot`,
`readFileSync`, and `join` imports plus an explicit try/catch).
Replace the `isRust` boolean parameter with file-path dispatch, and
cap the per-var example set at insert time to bound memory under
`scope: 'all'`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
All NX_* env var reads live in `packages/nx`, so look up that
project's files directly instead of walking every project with a
scope filter. Also inline the one-use `failure` helper.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Addresses review feedback from Craigory:
- Drop Rust env! macro regex (compile-time, not runtime).
- Document NX_CACHE_FAILURES, NX_NATIVE_COMMAND_RUNNER,
  NX_WRAPPER_SKIP_INSTALL, NX_SKIP_NATIVE_FILE_CACHE, and
  NX_SOCKET_DIR in the main Nx table.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Addresses review feedback from Craigory:
- Drop Rust env! macro regex (compile-time, not runtime).
- Document NX_CACHE_FAILURES, NX_NATIVE_COMMAND_RUNNER,
  NX_WRAPPER_SKIP_INSTALL, NX_SKIP_NATIVE_FILE_CACHE, and
  NX_SOCKET_DIR in the main Nx table.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Give NX_DAEMON_SOCKET_DIR its own row instead of only mentioning it
inline under NX_SOCKET_DIR, and drop it from the conformance rule's
ignore list.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
It is not a deprecated alias — NX_SOCKET_DIR covers both daemon and
forked process sockets, while NX_DAEMON_SOCKET_DIR scopes the
override to the daemon socket only. Match the existing troubleshooting
and nx-daemon concept docs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Tracing getSocketDir() in tmp-dir.ts and get_socket_dir() in
socket_path.rs shows both vars feed the same function used for
every Nx socket (daemon, forked process, plugin, nx-console) —
they are aliases, not scope-separated overrides. Update the env
var reference, unix-sockets troubleshooting page, and nx-daemon
concept doc to recommend NX_SOCKET_DIR and describe
NX_DAEMON_SOCKET_DIR as a legacy fallback.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The previous table had ~60 entries in a single block that was
overwhelming to scan. Group everyday settings (bail, base/head,
cache dirs, parallel, dry run, verbose logging, migration basics,
TUI) under Common, and move debugging/internals (native runner,
logging, plugin isolation, v8 serializer, wrapper, socket dirs,
self-hosted cache, profiling, provenance) under Advanced. Rows
are sorted alphabetically within each section for faster lookup.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@barbados-clemens barbados-clemens force-pushed the cu/env-var-conformance-docs branch from c348701 to d97c1b2 Compare April 22, 2026 17:36
@barbados-clemens barbados-clemens merged commit 3d9bc7a into master Apr 22, 2026
24 checks passed
@barbados-clemens barbados-clemens deleted the cu/env-var-conformance-docs branch April 22, 2026 18:28
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants