Skip to content

Commit 562d385

Browse files
authored
docs: detect orphaned URLs, restore deleted-tutorial redirects, restructure llms.txt (#23567)
## Why An agent pointed at docs.aztec.network hit 404s, gave up, fell back to stale training data, and missed `SingleUseClaim` (the right primitive). Causes: pages deleted without redirects, and `llms.txt` truncating its API index at 100 of ~1,300 entries (alphabetical, hiding everything past `m`). Three fixes + a CI guard so the deletion case can't recur silently. ## What changed **1. Orphan-URL detection** — `docs/scripts/check_orphaned_urls.sh` (new) - Flags any baseline URL that no longer resolves **and** has no `netlify.toml` redirect (inverse of `validate_redirect_targets.sh`). - Handles `*` splat / `:name` placeholders. `FAIL_ON_ORPHAN=1` = hard gate (default warn-only). **2. Restored redirects** — `docs/netlify.toml` - 301s for 5 previously-404 pages (4 deleted in #16788, + bare `/developers/getting_started`), e.g. `private_voting_contract` → `state_variables` (where `SingleUseClaim` lives). **3. llms.txt restructure** — `docs/scripts/append_api_docs_to_llms.js` - Spec-compliant root: single H1 + `>` summary, `llms-full.txt` link up top, droppable `## Optional` section ([awesome-aztec](https://github.com/AztecProtocol/awesome-aztec)). - Hub-and-spoke (Cloudflare/Next/Svelte pattern): root `## API Reference` is now 2 links, not a ~286-module dump (root API content 84 KB → <1 KB). - Full per-symbol index moves to scoped files an on-task agent fetches: `aztec-nr-api/mainnet/llms.txt` (~286 modules, structs/traits/fns inline — `SingleUseClaim` stays grep-able) and `typescript-api/mainnet/llms.txt`. Each is its own single-H1 doc. `llms-full.txt` unchanged. - Fail-loud sentinel: build aborts if the rustdoc index collapses below floors (≥50 modules, ≥100 item names; currently 286/662), so a future nargo HTML change can't silently gut the symbol index. - Build: bare `docusaurus` → `yarn docusaurus` in `package.json` + `clean.sh` (use repo-pinned binary, not global PATH). **4. CI guard** — `docs/bootstrap.sh` + `docs/snapshots/published-urls.txt` - `check_orphaned_urls` runs on every docs PR with `FAIL_ON_ORPHAN=1`. Catches accidental deletion-without-redirect (the incident class above). - Baseline is read from the **base branch** (`git show origin/$GITHUB_BASE_REF:…`), not the working tree, so a PR can't weaken its own gate by editing the snapshot. (This PR introduces the file, so it falls back to the working-tree snapshot for itself; tamper-resistance applies to every PR after merge.) - `refresh_url_snapshot.sh` only grows the protected set (registering newly-published pages); retiring a page needs just the redirect, not a snapshot edit. ## Test plan - [x] `validate:redirects` + `validate:api-ref-links` clean - [x] `check_orphaned_urls.sh`: 162 resolved, 0 orphaned; flags synthetic deletions - [x] Full `yarn build`: root single-H1 + `llms-full.txt` link + `## API Reference` (2 dynamic-version links) + `## Optional`; scoped indexes single-H1, `SingleUseClaim` present, 9 TS package links - [x] No-API build: only `## Optional`, single H1, no scoped files - [x] Sentinel fires (exit 1) when the rustdoc index is forced below the floor - [x] Base-branch baseline sourcing verified (falls back to working-tree snapshot for this introducing PR, as designed) - [x] `refresh_url_snapshot.sh` idempotent; Codex reviewed - [x] [Netlify preview](https://deploy-preview-23567--aztec-docs-dev.netlify.app): all 5 redirects 301 to targets that resolve 200; `/llms.txt`, `/llms-full.txt`, `/aztec-nr-api/mainnet/llms.txt`, `/typescript-api/mainnet/llms.txt` all serve 200; scoped module links resolve Refs: #16788, #17168, #23572 (scoped-index split, merged here).
2 parents 185f1de + 9ebff63 commit 562d385

12 files changed

Lines changed: 1028 additions & 54 deletions

docs/bootstrap.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,54 @@ function test {
5353
test_cmds | parallelize
5454
}
5555

56+
function check_orphaned_urls {
57+
echo_header "Check orphaned URLs"
58+
# Source the baseline from the base branch, not the working tree, so a PR
59+
# cannot weaken its own gate by deleting URLs from the snapshot in the same
60+
# diff. The committed snapshot only grows the protected set for future PRs;
61+
# the check a PR must satisfy is the base-branch version it cannot edit.
62+
local snapshot=snapshots/published-urls.txt
63+
local base_ref="${GITHUB_BASE_REF:-next}"
64+
local tmp
65+
tmp=$(mktemp)
66+
# shellcheck disable=SC2064
67+
trap "rm -f '$tmp'" RETURN
68+
69+
# Resolve the base branch first, distinguishing "base unreachable" from "base
70+
# reachable but snapshot absent". Only the latter is a legitimate fallback (it
71+
# happens for the PR that first introduces the snapshot). Treating an
72+
# unreachable base as a fallback would silently reopen the bypass.
73+
local base_obj=""
74+
if git rev-parse --verify -q "origin/${base_ref}" >/dev/null; then
75+
base_obj="origin/${base_ref}"
76+
elif git fetch -q origin "$base_ref" 2>/dev/null; then
77+
base_obj="FETCH_HEAD"
78+
fi
79+
80+
local baseline
81+
if [[ -n "$base_obj" ]]; then
82+
if git show "${base_obj}:docs/${snapshot}" >"$tmp" 2>/dev/null; then
83+
echo "Using base-branch baseline (${base_obj})."
84+
baseline="$tmp"
85+
else
86+
echo "Base branch ${base_ref} has no snapshot yet; using working-tree snapshot (introducing PR)."
87+
baseline="$snapshot"
88+
fi
89+
elif [[ "${CI:-0}" -eq 1 ]]; then
90+
# In CI the base must be reachable; downgrading to the PR's own editable
91+
# snapshot would reopen the bypass this gate exists to close.
92+
echo "ERROR: cannot resolve base branch origin/${base_ref} to source the orphan-check baseline." >&2
93+
return 1
94+
else
95+
echo "Base branch origin/${base_ref} unavailable; using working-tree snapshot (local run)."
96+
baseline="$snapshot"
97+
fi
98+
99+
local rc=0
100+
FAIL_ON_ORPHAN=1 ./scripts/check_orphaned_urls.sh "$baseline" || rc=$?
101+
return $rc
102+
}
103+
56104
function check_references {
57105
if [[ "${GITHUB_EVENT_NAME:-}" != "merge_group" ]]; then
58106
echo "Skipping doc reference check (only runs in merge queue)."
@@ -81,11 +129,13 @@ case "$cmd" in
81129
build_examples
82130
build_docs
83131
test
132+
check_orphaned_urls
84133
check_references
85134
;;
86135
"")
87136
build_examples
88137
build_docs
138+
check_orphaned_urls
89139
check_references
90140
;;
91141
"hash")

docs/docs-developers/ai_tooling.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ For Claude Code, create a `CLAUDE.md` file in your project root. For Codex, crea
2222
```markdown
2323
# Aztec Project
2424

25-
## Critical: Use `aztec` CLI, not `nargo` directly
25+
## Critical: Use the `aztec` CLI, not `nargo` or `bb` directly
2626

27-
This is an Aztec smart contract project. Always use the `aztec` CLI wrapper instead of calling `nargo` directly:
27+
This is an Aztec smart contract project. Always use the `aztec` CLI wrapper instead of calling `nargo` or `bb` (the Barretenberg prover) directly:
2828

2929
- **Compile**: `aztec compile` (NOT `nargo compile`). Using `nargo compile` alone produces incomplete artifacts.
3030
- **Test**: `aztec test` (NOT `nargo test`).
31+
- **Prove**: NEVER call `bb` directly. Proof generation is handled for you by the PXE through the `aztec` CLI and `aztec.js`. There is no contract-development workflow that runs `bb` by hand.
3132
- **Other nargo commands** like `aztec-nargo fmt` and `aztec-nargo doc` are fine to use directly. The Aztec installer exposes the bundled `nargo` as `aztec-nargo`; bare `nargo` resolves to your own install (if any), not the bundled one.
3233

3334
## Error Handling
@@ -57,7 +58,7 @@ This prevents the two most common AI mistakes: using `nargo compile`/`nargo test
5758

5859
### Why this matters
5960

60-
LLMs have extensive training data for `nargo` (the standalone Noir compiler) but limited exposure to the `aztec` CLI wrapper. Without explicit instructions, they default to `nargo compile`, which produces artifacts missing the AVM transpilation step.
61+
LLMs have extensive training data for `nargo` (the standalone Noir compiler) and `bb` (the Barretenberg prover CLI) but limited exposure to the `aztec` CLI wrapper. Without explicit instructions, they default to `nargo compile` (which produces artifacts missing the AVM transpilation step) or reach for `bb` to generate proofs. In an Aztec project, compilation and proving both go through the `aztec` tooling.
6162

6263
## MCP servers
6364

docs/docs-words.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,4 +441,5 @@ reentrancy
441441
variadic
442442
Wonderland
443443
indistinguishability
444+
llmstxt
444445
nightlies

docs/llms.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Aztec Protocol Documentation
2+
3+
> Privacy-centric zkRollup for Ethereum. This repository builds the developer documentation site; the canonical `llms.txt` is auto-generated from it and published on the docs site.
4+
5+
The published, always-current LLM-friendly files live on the docs site:
6+
7+
- [llms.txt](https://docs.aztec.network/llms.txt): navigational index of the documentation, following the [llmstxt.org](https://llmstxt.org) standard.
8+
- [llms-full.txt](https://docs.aztec.network/llms-full.txt): the complete documentation as a single file.
9+
10+
These are regenerated on every docs build, so prefer them over this checked-in pointer for the current API surface and guides.
11+
12+
## AI tooling
13+
14+
- [AI Tooling guide](https://docs.aztec.network/developers/ai_tooling): recommended `CLAUDE.md` / `AGENTS.md` instructions, MCP servers, and skills for Aztec and Noir development. Read this first when setting up an AI coding agent for an Aztec project.

docs/netlify.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,37 @@
425425
from = "/developers/docs/tutorials/faceid_wallet"
426426
to = "/developers/docs/tutorials/contract_tutorials/counter_contract"
427427

428+
# =============================================================================
429+
# ACTIVE REDIRECTS: Removed contract tutorials (PR #16788)
430+
# These pages were deleted without a redirect; LLMs trained on older versions
431+
# of the docs still link to them. Send each to the closest current page.
432+
# =============================================================================
433+
[[redirects]]
434+
from = "/developers/docs/tutorials/contract_tutorials/private_voting_contract"
435+
to = "/developers/docs/aztec-nr/framework-description/state_variables"
436+
status = 301
437+
438+
[[redirects]]
439+
from = "/developers/docs/tutorials/contract_tutorials/crowdfunding_contract"
440+
to = "/developers/docs/tutorials/contract_tutorials/token_contract"
441+
status = 301
442+
443+
[[redirects]]
444+
from = "/developers/docs/tutorials/contract_tutorials/nft_contract"
445+
to = "/developers/docs/aztec-nr/standards/aip-721"
446+
status = 301
447+
448+
[[redirects]]
449+
from = "/developers/docs/tutorials/contract_tutorials/write_accounts_contract"
450+
to = "/developers/docs/aztec-js/how_to_create_account"
451+
status = 301
452+
453+
# Bare /developers/getting_started landed on no page after the local/testnet split
454+
[[redirects]]
455+
from = "/developers/getting_started"
456+
to = "/developers/getting_started_on_local_network"
457+
status = 301
458+
428459
# Legacy network paths - SPECIFIC PATHS MUST COME BEFORE WILDCARDS
429460
# (Netlify processes redirects top-to-bottom, first match wins)
430461
[[redirects]]

docs/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33
"version": "0.0.0",
44
"private": true,
55
"scripts": {
6-
"build": "yarn clean && yarn preprocess && yarn spellcheck && yarn preprocess:move && yarn validate:redirects && yarn validate:api-ref-links && docusaurus build && node scripts/augment_sitemap.js && node scripts/append_api_docs_to_llms.js",
6+
"build": "yarn clean && yarn preprocess && yarn spellcheck && yarn preprocess:move && yarn validate:redirects && yarn validate:api-ref-links && yarn docusaurus build && node scripts/augment_sitemap.js && node scripts/append_api_docs_to_llms.js",
77
"validate:redirects": "./scripts/validate_redirect_targets.sh",
88
"validate:api-ref-links": "./scripts/validate_api_ref_links.sh",
9+
"check:orphaned-urls": "./scripts/check_orphaned_urls.sh",
910
"clean": "./scripts/clean.sh",
1011
"dev:netlify": "yarn netlify dev",
1112
"generate:aztec-nr-api": "./scripts/aztec_nr_docs_generation/generate_aztec_nr_docs.sh",
1213
"generate:typescript-api": "./scripts/typescript_api_generation/generate_ts_api_docs.sh",
1314
"generate:node-api-reference": "./scripts/node_api_reference_generation/generate_node_api_reference.sh",
1415
"preprocess": "yarn node -r dotenv/config ./src/preprocess/index.js",
1516
"preprocess:move": "sh scripts/move_processed.sh",
16-
"serve": "docusaurus serve",
17+
"serve": "yarn docusaurus serve",
1718
"spellcheck": "yarn cspell",
1819
"spellcheck:appendwords": "yarn cspell --words-only --unique | sort --ignore-case >> docs-words.txt",
19-
"start": "yarn clean && yarn preprocess && yarn generate:aztec-nr-api && docusaurus start --host ${HOST:-localhost}",
20+
"start": "yarn clean && yarn preprocess && yarn generate:aztec-nr-api && yarn docusaurus start --host ${HOST:-localhost}",
2021
"test": "node --test src/preprocess/__tests__/*.test.js",
2122
"test:preprocess": "node --test src/preprocess/__tests__/*.test.js"
2223
},

0 commit comments

Comments
 (0)