Add docs-referenced file validation gate - #971
Sheri Gilley (sdgilley) wants to merge 3 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical and moderate findings affect enforcement and validation correctness.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adds a fork-safe automated gate validating files and regions referenced by published Learn articles.
Changes:
- Adds an 86-file documentation reference manifest.
- Implements Python validation for paths, snippets, and notebook cells.
- Adds workflows, contract tests, rollout guidance, and CODEOWNERS protection.
File summaries
| File | Description |
|---|---|
.github/workflows/scripts-selftest.yml |
Runs checker contract tests. |
.github/workflows/docs-referenced-files.yml |
Defines the validation gate. |
.github/scripts/test/test_docs_referenced_files.py |
Provides hermetic checker coverage. |
.github/scripts/check-docs-referenced-files.README.md |
Documents usage and rollout. |
.github/scripts/check-docs-referenced-files.py |
Implements manifest and snippet validation. |
.github/docs-referenced-files.json |
Lists protected documentation paths. |
.github/CODEOWNERS |
Protects gate configuration and maintains migration ownership. |
Review details
Suppressed comments (2)
.github/scripts/check-docs-referenced-files.py:243
PurePosixPath(...).suffixis empty for a dotfile named exactly.env, so the.envmarker listed above is never selected. Delimited.enventries are rejected as unknown (and auto entries fall back to whole-file); special-case the basename so the advertised.envsupport actually scans# <id>markers.
suffix = PurePosixPath(path).suffix.lower()
.github/scripts/check-docs-referenced-files.py:563
- When an auto entry is added together with a new file, a file containing only an orphan closing tag has no opening names, so this returns
whole-fileand skipscheck_snippets; the malformed delimiter therefore passes. Select delimited mode whenevertagsis non-empty, not only when an opening name was discovered, so orphan closing tags are structurally checked as promised by the new-file contract test.
deduped = list(dict.fromkeys(tag.name for tag in tags if not tag.closing))
return (MODE_DELIMITED, deduped) if deduped else (MODE_WHOLE_FILE, [])
- Files reviewed: 7/7 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if disk.is_file(): | ||
| raw = disk.read_bytes() |
There was a problem hiding this comment.
Fixed in 517338d; worktree reads now reject symbolic links before reading their targets, with regression coverage.
| # Keep an entry explicit if it already was, even without --pin: pinning is a deliberate | ||
| # choice the docs team made for that file and a reseed must not silently undo it. | ||
| keep_explicit = previous is not None and previous.mode != MODE_AUTO | ||
| if not pin and not keep_explicit and not note: | ||
| files.append(path) | ||
| continue | ||
| try: | ||
| entry_mode, snippets = discover_expected(tree.read_text(path), path) |
There was a problem hiding this comment.
Fixed in 517338d; ordinary seeding now preserves existing modes, snippets, and notes, with regression coverage.
Co-authored-by: sdgilley <3650506+sdgilley@users.noreply.github.com>
Co-authored-by: sdgilley <3650506+sdgilley@users.noreply.github.com>
Co-authored-by: Brandon Miller <42854725+brandom-msft@users.noreply.github.com>
Published Learn articles reference sample paths and snippet identifiers directly, so deleting, moving, or removing a referenced region can break the docs build. This replaces routine per-file Docs team approval with an automated, fork-safe PR check.
What changed
Rollout note
The new
docs-referenced-files / checkcontext must be configured as required onmain, and the manifest, checker, and workflow paths must be protected from unreviewed changes. After that rollout, the legacy per-file CODEOWNERS block can be removed.Validation
python3 .github/scripts/test/test_docs_referenced_files.py