Files
supabase/.agents/skills/ask-the-docs/reference/federated-docs.md
0bbd64743c docs: move inspect and advisors into observability (#49503)
<!-- CURSOR_AGENT_PR_BODY_BEGIN -->
## Stack

Draft stack extracted from `docs/monitoring`. Merge bottom-up.
Troubleshooting / debugging-guide rewrite is out of scope.

1. **#49503** move inspect and advisors ← **this PR**
2. #49501 split Studio logs from ClickHouse queries
3. #49500 treat reports as signal dashboards
4. #49502 add Observe the data hub
5. #49506 add agent setup components
6. #49504 add hire-an-agent templates
7. #49505 restructure observability nav and overview

## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Docs update. First layer in the observability stack.

## What is the current behavior?

Inspect and advisors live under Database (`/guides/database/inspect`,
`/guides/database/database-advisors`). Observability readers have to
leave the monitoring section to find them.

## What is the new behavior?

- Moves inspect into `/guides/monitoring-and-debugging/inspect`
- Adds `/guides/monitoring-and-debugging/advisors` (replaces the
Database Advisors page)
- Adds redirects and updates Studio/docs links so old URLs keep working
- Adds both pages to the existing Monitoring nav so they are
discoverable before the later IA PR

## Additional context

Inspect and advisors pages render as standard MDX. Redirects cover
`/docs/guides/database/inspect`,
`/docs/guides/database/database-advisors`, and
`/docs/guides/database/database-linter`. Debugging-guide content is
unchanged except the inspect URL.

## Self-review

- No leftover `/guides/database/inspect` or
`/guides/database/database-advisors` links in docs guides or Studio
linter/AI surfaces (historical blog posts left as-is)
- Smoke test path updated to
`/docs/guides/monitoring-and-debugging/advisors`
<!-- CURSOR_AGENT_PR_BODY_END -->

<div><a
href="https://cursor.com/agents/bc-a3cb5ece-925b-4046-b58a-5d69e9a9d794?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a
href="https://cursor.com/background-agent?bcId=bc-a3cb5ece-925b-4046-b58a-5d69e9a9d794&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
alt="Open in Cursor" width="131" height="28"
src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div>



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added a centralized Advisors guide for security and performance
checks.
- Updated database inspection guidance with live Postgres statistics,
cache hit-rate context, and query-analysis resources.

- **Documentation**
- Reorganized Advisors and database inspection content under Monitoring
and Debugging.
- Updated navigation, cross-references, in-product help links, and CLI
documentation links.
- Added permanent redirects from previous documentation URLs to preserve
access.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Saxon Fletcher <SaxonF@users.noreply.github.com>
Co-authored-by: Nik Richers <nik@validmind.ai>
2026-09-04 13:38:36 +10:00

228 lines
11 KiB
Markdown

# Federated docs
`apps/docs` can pull **markdown (and other files) from external GitHub repos**
at **build or request time**, then render them inside the normal docs shell.
Content lives in ecosystem repos (client libs, extensions, tooling) without
duplicating into `apps/docs/content`.
Documented upstream in root **`DEVELOPERS.md`** → "Federated docs."
> **The maintainers treat this as a known liability.** See
> [`docs-app-direction.md`](./docs-app-direction.md) for the full context
> (lack of editorial oversight, brittle builds, quality drift). Treat
> federated content as a liability when reviewing or debugging.
## Why federate
- **No duplication** — e.g. `supabase/vecs` docs stay in the vecs repo.
- **Automatic sync** — fetched during the docs build (or on cached
revalidation), not hand-copied.
- **Native feel** — same `GuideTemplate`, nav, typography, and search surface
as first-party guides.
- **Flexible placement** — can embed external docs at nearly any path under
`/guides/`.
Trade-off: **integration is manual and brittle**. Each federated section
needs its own route file, `pageMap`, link transform, and often custom remark
plugins.
## Build-time flow
```mermaid
flowchart TB
subgraph upstream ["External repos"]
PG["supabase/pg_graphql"]
VECS["supabase/vecs"]
WRAP["supabase/wrappers"]
TF["supabase/terraform-provider-supabase"]
CI["supabase/setup-cli"]
SPL["supabase/splinter"]
SKILLS["supabase/agent-skills"]
end
subgraph fetch ["Fetch layer — lib/octokit.ts"]
APP["GitHub App auth<br/>DOCS_GITHUB_APP_*"]
API["getGitHubFileContents()"]
CACHE["fetchRevalidatePerDay<br/>(Next.js cache, retry up to 5x)"]
APP --> API --> CACHE
end
subgraph route ["Per-section route — app/guides/.../page.tsx"]
MAP["pageMap<br/>(slug → remoteFile + meta)"]
GET["getContent()"]
MAP --> GET
end
subgraph transform ["MDX pipeline"]
RM["remark plugins<br/>Admonition, Tabs, removeTitle"]
RH["rehype plugins<br/>linkTransform + rehypeSlug"]
RM --> RH
end
subgraph render ["Render"]
GT["GuideTemplate / GuideMdxContent"]
OUT["/docs/guides/..."]
GT --> OUT
end
upstream --> API
GET --> RM
RH --> GT
```
### Step-by-step
1. **Route file** defines `org`, `repo`, `branch` (or tag), `docsDir`, and a
**`pageMap`** — each entry maps a local slug to a remote markdown file
plus page metadata.
2. **`getGitHubFileContents()`** fetches file content via a **GitHub App**
(`DOCS_GITHUB_APP_ID`, `DOCS_GITHUB_APP_INSTALLATION_ID`,
`DOCS_GITHUB_APP_PRIVATE_KEY`). Uses **once-per-day revalidation** by
default (`fetchRevalidatePerDay`).
3. Raw markdown is passed through **remark/rehype plugins** to bridge dialect
gaps.
4. **`linkTransform` + custom `urlTransform`** rewrite relative links from
the source repo into `/docs/guides/...` paths (or fall back to the upstream
docs site / GitHub).
5. Output is rendered with **`GuideTemplate`** so federated pages look like
native guides. **Edit on GitHub** links point at the source repo file.
> Note: `DEVELOPERS.md` still mentions `getStaticProps()` — the current App
> Router implementation uses async server components + `generateStaticParams`
> instead, but the idea is the same: fetch remote markdown at build time.
## Federated sources (inventory)
| Local path | Source repo | Ref / branch | Pattern |
| ------------------------------------------- | -------------------------------------- | ------------------------------ | ------------------------------------------------- |
| `/guides/graphql/*` | `supabase/pg_graphql` | `master` | Fully federated; `pageMap` per page |
| `/guides/ai/python/*` | `supabase/vecs` | `main` | Fully federated |
| `/guides/deployment/ci/*` | `supabase/setup-cli` | `gh-pages` | Fully federated |
| `/guides/deployment/terraform/*` | `supabase/terraform-provider-supabase` | branch in `terraformConstants` | Federated prose pages |
| `/guides/deployment/terraform/reference` | same | same | Federated **JSON schema** (not MDX) |
| `/guides/database/extensions/wrappers/*` | `supabase/wrappers` | **release tag** `docs_v*.*.*` | **Hybrid** — local MDX + federated catalog |
| `/guides/monitoring-and-debugging/advisors` | `supabase/splinter` | `main` | **Dynamic listing** — all `docs/*.md` files |
| AI Skills index | `supabase/agent-skills` | `main` | Lists `skills/*/SKILL.md` at runtime |
| `$CodeSample` directive | various | commit SHA only | Snippets via `getGitHubFileContentsImmutableOnly` |
### Related patterns (not quite "federated docs")
| Pattern | Source | Mechanism |
| -------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------ |
| **AI prompts** | `examples/prompts/*.md` | Copied into `apps/docs/examples` at build (`codegen:examples`); nav injected in getting-started layout |
| **Integrations nav** | Supabase `partners` table | `integrations/layout.tsx` fetches approved partners (external URLs) |
| **Reference docs** | `apps/docs/spec/` | Generated locally, not fetched from GitHub — see [`build-pipeline.md`](./build-pipeline.md) |
## How to spot a federated page in the repo
- Look for a **dynamic route** (`[[...slug]]/page.tsx`, `[slug]/page.tsx`)
instead of content-only routing.
- Search for **`// We fetch these docs at build time from an external repo`**
or **`getGitHubFileContents`**.
- Check for a local **`pageMap`** array mapping slugs to `remoteFile` names.
- GraphQL is listed in `PUBLISHED_SECTIONS` comments as _"technically
published, but completely federated"_ — no MDX under `content/guides/graphql/`.
Canonical starter example:
`apps/docs/app/guides/ai/python/[slug]/page.tsx` (vecs).
## Link and markdown transforms
External repos often use **MkDocs Material** or similar dialects. Supabase
docs do not understand those natively.
### Remark plugins (`lib/mdx/plugins/`)
| Plugin | Purpose |
| ------------------- | ----------------------------------------------- |
| `remarkAdmonition` | `!!! note` / `!!! warning` → `<Admonition>` |
| `remarkTabs` | pymdownx tab syntax → Supabase tabs |
| `remarkRemoveTitle` | Strip duplicate H1 when title comes from `meta` |
New upstream syntax may need a **new remark plugin** — called out explicitly
in `DEVELOPERS.md`.
### Link transform (`rehypeLinkTransform.ts`)
Each federated route defines its own **`urlTransform`** function:
- **Relative `.md` links** → mapped via `pageMap` to `/docs/guides/...` (or
section-relative slug).
- **Unmapped relative links** → fall back to upstream site (e.g.
`https://supabase.github.io/vecs/...`) or raw GitHub blob URL (terraform).
- **Absolute URLs** → passed through unchanged.
Wrappers additionally rewrites **`../assets/`** image paths to
`raw.githubusercontent.com` URLs tied to the docs release tag.
## Known failure modes
Federated docs are a frequent source of **content quality issues** and
**broken links**.
### Broken or wrong links
- **`pageMap` is manual** — upstream rename/remove → broken link until
someone updates the route file in `supabase/supabase`.
- **`urlTransform` is per-section** — logic differs between graphql, vecs,
terraform, wrappers, etc.
- **Unmapped pages fall back externally** — users leave the docs site or land
on a GitHub pages URL that may not match the embedded path structure.
- **Absolute links in upstream** pass through untouched — may point at old
domains or anchors that moved.
- **Cross-links between federated and native guides** are not automatic;
upstream authors don't know Supabase URL shapes.
### Content quality
- **No editorial gate in `apps/docs/content`** — upstream tone, structure,
and freshness vary.
- **Dialect mismatches** — unsupported mkdocs extensions render as raw text
or fail MDX compile until a plugin is added.
- **Duplicate titles** — mitigated by `removeTitle` / `removeRedundantH1`,
but layout can still look off.
- **Stale content** — daily GitHub cache means upstream fixes may not appear
until revalidation; wrappers pin to **release tags** which can lag further.
### Operational / dev failures
- **GitHub App credentials required** — without `DOCS_GITHUB_APP_*`, fetches
fail. `$CodeSample` with external repos shows a **local dev warning** and
does not render real content.
- **GitHub API timeouts** — `database-advisors` catches fetch errors and
shows a degraded view with a link to GitHub; build may still succeed with
partial content.
- **Wrappers tag resolution** — `getLatestDocsTag()` queries `docs_v*.*.*`
tags; if tagging breaks, federated wrapper pages throw at build time.
- **Dev mode gaps** — some federated routes return **empty
`generateStaticParams` in dev** (`IS_DEV`), so pages may 404 locally unless
you hit them via production build or adjust params.
### Navigation drift
- Sidebar entries for federated sections are often **hard-coded** in
`NavigationMenu.constants.ts` plus optional **`additionalNavItems`**
injection (prompts, integrations).
- New upstream pages do not appear in nav until a maintainer adds them to
`pageMap` **and** navigation config.
## When to federate vs copy into `content/`
Federate when:
- The canonical docs live in another repo and change frequently.
- Maintainers of that repo own the content lifecycle.
Prefer `content/guides/` when:
- Editorial control, consistent voice, and link stability matter.
- Content is tightly coupled to Supabase product UI and cross-links.
## Related
- [`app-map.md`](./app-map.md) — runtime + markdown export pipelines.
- [`build-pipeline.md`](./build-pipeline.md) — where federated fetches sit
in the overall build.
- [`docs-app-direction.md`](./docs-app-direction.md) — context on the
federated-docs liability and long-term direction.