Skip to content

docs: inherit feature states from ancestor routes in the docs sidebar - #31481

Closed
coder[bot] wants to merge 5 commits into
mainfrom
docs/ai-governance-state-inheritance
Closed

coder[bot] wants to merge 5 commits into
mainfrom
docs/ai-governance-state-inheritance

Conversation

@coder

@coder coder Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A feature state in docs/manifest/ now applies to a route and all its descendants, so each state is set once on the highest route it applies to.
docsmanifestgen check rejects a route that repeats an ancestor's state, and the repeated states on main are removed.

State model

  • Put a state on the highest route it applies to.
  • Add a state to a descendant only when it is new, such as an early access page inside a Premium section.
  • The sidebar shows a pill on the route that sets the state and on descendants whose state differs.
  • Every page shows its full state, own plus inherited, under the title.

Changes

  • docsmanifestgen check (make lint/docs-manifest) fails when a route repeats an ancestor's state, following include files and overlays, or lists a state twice.
    It runs only after the manifest builds cleanly.
    Table-driven tests in scripts/docsmanifestgen/state_test.go.
  • Keep state: [premium] on AI Governance and External provisioners only.
    Remove the 27 states their descendants repeat in docs/manifest/ai-governance/** and docs/manifest/install/operate/provisioners.yml, and regenerate docs/manifest.json.
  • Document the model in contributing/documentation.md (new "Feature states" section with a YAML example), docs/.style/content-guidelines.md, and the doc-check skill.

Important

Inherited pills under the page title and the new sidebar behavior need the matching docs-engine change (DOCS-1440).
Merge this after that ships, or child pages show no state pill until it does.

Testing

  • go test ./scripts/docsmanifestgen/... ./scripts/docgenenv/...
  • golangci-lint run ./scripts/docsmanifestgen/...
  • GOOS=windows and GOOS=darwin go vet ./scripts/docsmanifestgen/
  • make lint/docs-manifest, make lint/markdown, make lint/docs-redirects
  • make gen/docs-manifest leaves the tree clean.
Decision log: rebase onto main after #31645
  • docs: promote the AI sections and Templates to the top level of the sidebar #31645 (merged 2026-11-04) moved AI Governance to a top-level section with Agent Firewall and AI Gateway nested under it, and added the ai-coder/... redirects.
    That covered this PR's move commits, link and URL updates, and redirects, which caused the conflicts.
  • The branch was rebuilt on main: the two move commits were dropped, and the four state-tooling and guidance commits were cherry-picked.
    The manifest cleanup was redone as a new commit against main's layout, using the new lint's output as the list of repeated states.
  • Agent Relay is now top-level with state: [premium, beta] and no child states, so it needs no change.
  • Conflicts in content-guidelines.md and the doc-check skill were resolved to keep main's newer text (Vale word-choice updates and relative redirect syntax) and apply only the feature-states lines.
  • The pre-rebase head was a797f59737.

Generated by Coder Agents on behalf of @nickvigilante.

@github-actions github-actions Bot added the community Pull Requests and issues created by the community. label Oct 29, 2026

@nickvigilante nickvigilante left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we move AI Governance to be at the top level, as a sibling of ai-coder/ and immediately following it instead of as a child of ai-coder/?


Reviewed the Go changes in scripts/docsmanifestgen. The repeated-state check is correct on the PR tree: tests and golangci-lint pass, and adding state: [premium] to ai-gateway.yml fails check against the AI Governance ancestor, as expected. All inline comments are non-blocking. These tests run only on Linux in CI. go vet passes for Windows and macOS (GOOS=windows and GOOS=darwin), and a manual check with Windows line endings (CRLF) behaved correctly.

🤖 Review generated with Coder Agents on behalf of @nickvigilante.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

For the sections you've added to this doc, can you make it one sentence per line per the style guide?

Comment thread contributing/documentation.md Outdated
Follow these rules:

1. Put the state on the highest route it applies to.
For a Premium feature with several pages, set `state: [premium]` on the

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No hard wrap at 72 characters in any Markdown file anywhere in this repo. Don't change lines that weren't part of the existing diff; I'll handle that separately. Just don't hard wrap any new lines.

Comment thread scripts/docsmanifestgen/state.go Outdated
}

func checkStateRoute(dir, name string, r docgenenv.Route, crumb []string, inherited map[string]stateOrigin, seen map[string]bool, errs *[]error) {
crumb = append(crumb[:len(crumb):len(crumb)], r.Title)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit: docgenenv does this same copy-on-append as append(slices.Clip(crumb), r.Title) (scripts/docgenenv/sources.go lines 154, 243, 264, and 330).
Matching it reads more clearly than the three-index slice.
There's no suggestion block because the change also needs a slices import.

Comment thread scripts/docsmanifestgen/main.go Outdated
Comment on lines +62 to +65
if _, err := docgenenv.BuildManifest(sourcesDir, *docsDir); err != nil {
errs = append(errs, err)
}
errs = append(errs, repeatedStates(sourcesDir)...)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This runs the second include walker even when BuildManifest has already rejected the tree.
repeatedStates resolves includes with path.Clean, not the loader's sourceRel, so on an invalid tree it follows paths the loader refuses.
I tried this in a temp tree with include: ../outside.yml.
BuildManifest rejects the path, but repeatedStates still decodes the file outside the sources directory and reports a state error for it.
On an include cycle, the per-section seen map is the only thing that stops unbounded recursion, and no test case covers it.

If the walker runs only after BuildManifest succeeds, it sees only trees where every include is local, a .yml file, and used once.
I applied this locally: go test ./scripts/docsmanifestgen/ and docsmanifestgen check on the PR tree both still pass.
The cost is that state errors show up only after structural errors are fixed.
If you take it, update the last sentence of the repeatedStates doc comment, and seen can go.
If you'd rather report both in one run, move the walker into docgenenv so it can reuse sourceRel, and add an include-cycle case to TestRepeatedStates.

Suggested change
if _, err := docgenenv.BuildManifest(sourcesDir, *docsDir); err != nil {
errs = append(errs, err)
}
errs = append(errs, repeatedStates(sourcesDir)...)
if _, err := docgenenv.BuildManifest(sourcesDir, *docsDir); err != nil {
errs = append(errs, err)
} else {
errs = append(errs, repeatedStates(sourcesDir)...)
}

Comment thread scripts/docsmanifestgen/state.go Outdated
func checkStateRoute(dir, name string, r docgenenv.Route, crumb []string, inherited map[string]stateOrigin, seen map[string]bool, errs *[]error) {
crumb = append(crumb[:len(crumb):len(crumb)], r.Title)
where := strings.Join(crumb, " > ")
own := make(map[string]stateOrigin, len(inherited)+len(r.State))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit: own holds the inherited states plus this route's, and it's what each child receives as inherited.
A name like states would match what it holds better than own, which reads as this route's states only.

Comment thread scripts/docsmanifestgen/state.go Outdated
*errs = append(*errs, xerrors.Errorf("%s: %s: state %q is already set on ancestor %q in %s; remove it, because a route inherits its ancestors' states", name, where, s, o.crumb, o.file))
continue
}
own[s] = stateOrigin{file: name, crumb: where}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Optional: state: [beta, beta] on a single route passes, because only inherited is checked.
That's outside the ancestor rule, so take it or leave it.
own already holds the inherited values, so a hit after the inherited check means this route lists the value twice.
I applied this locally with a StateListedTwiceOnOneRoute table case (state: [beta, beta] on Home, want home.yml: Home: state "beta" is listed more than once).
The package tests, docsmanifestgen check on the PR tree, and golangci-lint all pass.

Suggested change
own[s] = stateOrigin{file: name, crumb: where}
if _, ok := own[s]; ok {
*errs = append(*errs, xerrors.Errorf("%s: %s: state %q is listed more than once", name, where, s))
continue
}
own[s] = stateOrigin{file: name, crumb: where}

@linear-code

linear-code Bot commented Oct 29, 2026

Copy link
Copy Markdown

DOCS-1440

@coder coder Bot changed the title docs: nest AI Governance pages and inherit its Premium state docs: make AI Governance a top-level section and inherit its Premium state Oct 29, 2026
default and others added 5 commits November 10, 2026 00:05
A route's state applies to all of its descendants, so a descendant that
repeats an ancestor's state is redundant. docsmanifestgen check now
reports each such route with its file, breadcrumb, and the ancestor that
already sets the state.
Add a Feature states section to contributing/documentation.md with the
inheritance rules, a YAML example of a Premium parent with an early
access child, and what the sidebar and the page title show for each
route. Link to it from the content guidelines.
Run repeatedStates only when BuildManifest succeeds, so it no longer
needs to tolerate undecodable files or guard against repeated includes.
Use slices.Clip for copy-on-append, rename the per-route state map, and
report a state listed more than once on the same route.
AI Governance sets state: [premium], and External provisioners sets it
on its own route, so their descendants inherit it. Remove the repeated
values that docsmanifestgen check now rejects.
@nickvigilante
nickvigilante force-pushed the docs/ai-governance-state-inheritance branch from a797f59 to 1439340 Compare November 10, 2026 00:08
@nickvigilante
nickvigilante temporarily deployed to main November 10, 2026 00:08 — with GitHub Actions Inactive
@nickvigilante nickvigilante changed the title docs: make AI Governance a top-level section and inherit its Premium state docs: inherit feature states from ancestor routes in the docs sidebar Nov 10, 2026
@nickvigilante
nickvigilante temporarily deployed to main November 10, 2026 00:09 — with GitHub Actions Inactive
@nickvigilante

Copy link
Copy Markdown
Collaborator

Closing and reopening under a human author, as required for this repository.

@nickvigilante
nickvigilante temporarily deployed to main November 10, 2026 15:52 — with GitHub Actions Inactive
@nickvigilante
nickvigilante temporarily deployed to main November 10, 2026 15:52 — with GitHub Actions Inactive
@nickvigilante
nickvigilante temporarily deployed to main November 10, 2026 15:52 — with GitHub Actions Inactive
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 10, 2026
@nickvigilante
nickvigilante temporarily deployed to main November 10, 2026 15:52 — with GitHub Actions Inactive
@nickvigilante
nickvigilante temporarily deployed to main November 12, 2026 15:30 — with GitHub Actions Inactive

This branch was previously deployed

1 inactive deployment
main — 1439340d Deployed Nov 12, 2026 by nickvigilante via cla #254999
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

community Pull Requests and issues created by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant