← Back to Pull requests

docs: make shell examples pasteable and gate unquoted placeholders #3209

Closed
unknown closed this pull request without merging on Oct 13, 2026 12:45 UTC
View on GitHub
unknown unknown commented on Oct 13, 2026 12:22 UTC
Author

Summary

Shell examples in docs/ used bare <placeholder> arguments that bash reads as redirection, so the commands could not be pasted. This converts all 216 of them (144 lines, 21 files) to an assignment line plus a quoted expansion, and adds make check-docs-shell to make lint and the merge gate so new ones cannot land.

Motivation / Context

kubectl delete namespace <namespace> is a syntax error when pasted, and kubectl get pods <name> -n default runs with its output written to a file named -n whenever a file called name exists. The obvious fix, a bare ${NAMESPACE}, is worse: an unset variable expands to nothing and kubectl delete or helm uninstall runs with an argument missing. The issue asks for a conversion that stays fail-closed, plus a lint so the count does not drift back up.

Fixes: #2266
Related: N/A

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

  • New feature (non-breaking change that adds functionality)

  • Breaking change (fix or feature that would cause existing functionality to change)

  • Documentation update

  • Refactoring (no functional changes)

  • Build/CI/tooling
  • Component(s) Affected

  • CLI (cmd/aicr, pkg/cli)

  • API server (cmd/aicrd, pkg/server)

  • Recipe engine / data (pkg/recipe)

  • Bundler and deployers (pkg/bundler, pkg/component)

  • Collectors / snapshotter (pkg/collector, pkg/snapshotter)

  • Validator (pkg/validator)

  • Core libraries (pkg/errors, pkg/k8s)

  • Docs/examples (docs/, examples/)

  • Other: docs lint gate (tools/check-docs-shell, tools/mdx/check-docs-shell.mjs), Makefile, .github/workflows/merge-gate.yaml
  • Implementation Notes

    Conversion form. Every converted block assigns each variable in the same block before its first use, with a # replace with ... comment, and quotes every expansion ("${NAMESPACE}", "snapshot-rbac-${RUN_ID}/"). No block relies on a variable from an earlier block. Values that come from the output of an earlier step (run IDs, security group IDs, a replacement pod, the copyTo path) are assigned right after that step, and the comment says where to read them.

    Example values. For anything that deletes, uninstalls, drains, taints, labels, patches, applies, pushes, or opens network access, the example value cannot plausibly match a real resource: my-namespace, my-release, my-gpu-node, sg-0123456789abcdef0, and an obviously synthetic 0123456789abcdef... signer and digest for evidence pointers. A block pasted without editing fails with NotFound instead of acting on something real. Read-only commands use realistic values.

    Not converted.

  • Command synopses (aicr verify <bundle-dir> [flags]) and flag fragments are grammar, not commands, so their fences are now text. All 17 synopsis blocks in cli-reference.md were relabelled so the page stays consistent.

  • console transcripts, placeholders in comments, and quoted placeholders in untouched blocks are left alone. In blocks that were converted anyway, quoted placeholders were converted too so one block uses one style. The exception is --overrides JSON in eks-dynamo-networking.md, which keeps quoted placeholders with a comment saying to replace them, because parametrizing it needs escaped JSON.

  • ADRs under docs/design/ are point-in-time records and are not amended. The gate skips that directory by default.
  • One correction. aicr verify ./bundles/<bundle-dir> is now aicr verify ./bundles. aicr bundle -o ./bundles writes the bundle and its attestation/ directly into ./bundles; there is no subdirectory.

    The gate. tools/check-docs-shell reuses the check-docs-yaml driver and the pinned MDX parser in tools/mdx, so it finds the same fences Fern renders, including fences inside MDX components. tools/mdx/check-docs-shell.mjs lexes each bash/sh/shell/zsh block and reports any < that bash would treat as an operator and that closes like a placeholder (<name>, <a|b>, </path/x.yaml>, <your cluster name>) at file:line:col. It models quotes, escapes, comments, ${...}, arithmetic, and command substitution, including $(...) inside double quotes and inside heredocs with an unquoted delimiter. Real redirections such as <file, < file, <in >out, <in 2>err, <(cmd), and <<EOF pass.

  • The default scan lists Markdown under docs/ with git ls-files --cached --others --exclude-standard, so a new page is checked before it is added, and a gitignored local scratch file cannot fail make lint when CI would pass.

  • Like the sibling Node gates, it hard-fails in CI when Node is missing and warns and skips locally.

  • It is wired into make lint and the merge-gate docs-mdx job, which runs on docs-only PRs and is aggregated by the required gate check.
  • Follow-ups, not in this PR. Bare placeholders remain in demos/*.md and kwok/README.md, which are outside docs/ and not published. The Rekor block in supply-chain-verification.md still relies on ${DIGEST} from that page's setup section, as it did before.

    Testing

    make qualify                          # clean detached worktree of the final commit
    make check-docs-shell                 # OK: 470 shell block(s) in 89 Markdown file(s)
    bash tools/check-docs-shell_test.sh   # also under macOS /bin/bash 3.2 and with CI=1
    

  • make qualify passed in a clean worktree: coverage 85.1% against the 83% floor, make lint (including the new gate, MDX, MDX parse, and YAML gates), e2e, scan, api-diff, and openapi-diff.

  • tools/check-docs-shell_test.sh runs under make test. It pins the inert constructs, every reported shape with its line and column, the git-aware scan (ignored, untracked, and deleted-but-tracked files), MDX-nested fences with and without parser recovery, and fail-closed handling of a missing root, a failing find, a failing git ls-files, an unreadable file, and zero shell blocks.

  • 14 mutations of the checker and driver were each confirmed to fail the harness, among them deleting arithmetic, ${...}, ANSI-C, or heredoc handling, treating unquoted heredoc bodies as inert, and scanning ignored files.

  • Every changed shell block passes bash -n, and a scan confirms no variable is used before its assignment in the same block.

  • make check-docs-mdx, make check-docs-mdx-parse, and make check-docs-yaml pass.
  • No Go source changed, so the coverage gate does not apply.

    Risk Assessment

  • Low — Isolated change, well-tested, easy to revert

  • Medium — Touches multiple components or has broader impact

  • High — Breaking change, affects critical paths, or complex rollout
  • Rollout notes: The new lint fails any future docs change that adds an unquoted <placeholder> to a shell block. The error output shows the assign-then-quote fix, and docs/contributor/tests.md documents the gate. Nothing changes at runtime.

    Checklist

  • Tests pass locally (make test with -race)

  • Linter passes (make lint)

  • I did not skip/disable tests to make CI green

  • I added/updated tests for new functionality

  • I updated docs if user-facing behavior changed

  • Changes follow existing patterns in the codebase

  • Commits are signed off and cryptographically signed (git commit -s -S) — GPG signing info
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: lalitadithya Review duration: 22m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3209"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%
    Repository