Skip to content

Add docs-referenced file validation gate - #971

Draft
Sheri Gilley (sdgilley) wants to merge 3 commits into
mainfrom
sdgilley-shiny-waddle
Draft

Sheri Gilley (sdgilley) wants to merge 3 commits into
mainfrom
sdgilley-shiny-waddle

Conversation

@sdgilley

Copy link
Copy Markdown
Contributor

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

  • Adds a path-only manifest of 86 currently docs-referenced files.
  • Adds a standard-library Python checker that blocks missing or moved files, removed snippet delimiters, and deleted or renamed named notebook cells.
  • Compares bare manifest entries to the PR base revision, preserving simple one-path-per-line maintenance while detecting removals.
  • Adds the required-check workflow, hermetic contract coverage, and migration guidance in CODEOWNERS and the checker README.

Rollout note

The new docs-referenced-files / check context must be configured as required on main, 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

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI 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.

🟡 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(...).suffix is empty for a dotfile named exactly .env, so the .env marker listed above is never selected. Delimited .env entries are rejected as unknown (and auto entries fall back to whole-file); special-case the basename so the advertised .env support 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-file and skips check_snippets; the malformed delimiter therefore passes. Select delimited mode whenever tags is 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.

Comment on lines +213 to +214
if disk.is_file():
raw = disk.read_bytes()

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.

Fixed in 517338d; worktree reads now reject symbolic links before reading their targets, with regression coverage.

Comment thread .github/workflows/docs-referenced-files.yml Outdated
Comment thread .github/scripts/check-docs-referenced-files.py Outdated
Comment on lines +710 to +717
# 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)

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.

Fixed in 517338d; ordinary seeding now preserves existing modes, snippets, and notes, with regression coverage.

Copilot AI and others added 2 commits September 10, 2026 16:55
Co-authored-by: sdgilley <3650506+sdgilley@users.noreply.github.com>
Co-authored-by: sdgilley <3650506+sdgilley@users.noreply.github.com>
@sdgilley
Sheri Gilley (sdgilley) marked this pull request as draft September 11, 2026 17:46
Rob Vettor (robvet) pushed a commit to robvet/foundry-samples that referenced this pull request Sep 13, 2026
Co-authored-by: Brandon Miller <42854725+brandom-msft@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants