Skip to content

examples/ gitignore footgun: hand-authored .md/.json silently ignored by the catch-alls #290

Description

@dean0x

Background

PR #287 (cb44b56, Fix 5) gitignored the 78 generated examples/ outputs with
open-ended catch-alls plus a fixed negation list:

examples/**/*.md
!examples/**/README.md
examples/**/*.json
!examples/**/package.json
!examples/**/mds.json
!examples/**/vars.json
!examples/**/vars-minimal.json
!examples/**/tsconfig.json

.gitignore:22-32 already carries an accurate FOOTGUN WARNING describing the
consequence. This issue tracks closing it structurally rather than by comment.

Problem

Any newly hand-authored .md or .json under examples/ is silently
ignored unless someone remembers to add a matching ! exception first. The
failure is invisible in the worst way: git add reports nothing, git status
shows a clean tree, the file is simply absent from the commit, and the author
discovers it only when a fresh clone is missing an example.

CI structurally cannot catch this. The examples-gitignore-coverage job
added in PR #287 asserts the inverse property — that after mds build, no
generated output is left untracked. A hand-authored file that was never
committed does not exist in a CI checkout, so no job can observe its absence.

This is currently local discipline only, on a directory that is the project's
primary onboarding surface.

Proposed change

Two options; (a) is the structural fix, (b) is the cheap mitigation.

(a) Generate into a dedicated output directory. Have mds build write
example outputs to e.g. examples/**/out/ (or a top-level target/examples/)
and ignore only that path. examples/**/*.md stops being a catch-all, every
hand-authored file under examples/ becomes tracked by default, and the footgun
is designed out rather than documented. Costs: the example READMEs and the
examples-gitignore-coverage job both need updating, and side-by-side
.mds/.md output is arguably nicer for readers browsing on GitHub.

(b) Pre-commit check. A hook that runs
git status --porcelain --ignored=matching -- examples/ and warns when an
ignored examples/ file has no sibling .mds source — the signature of a
hand-authored file caught by a catch-all. This is exactly the check the original
examples-guard job attempted; it is meaningless in CI (fresh checkout, no such
files) but meaningful locally, which is precisely where the footgun fires. Pairs
naturally with the control-byte pre-commit hook.

Acceptance Criteria

  • A hand-authored examples/foo/notes.md added without a ! exception is
    surfaced to the author before commit (or is tracked by default under (a))
  • The examples-gitignore-coverage CI job still passes
  • .gitignore's FOOTGUN WARNING is updated or removed to match the new reality
  • If (a): example READMEs and .gitignore updated; output paths documented

Reference

  • PR chore: harden release machinery (5 independent fixes) #287 (cb44b56) Fix 5 — introduced the catch-alls
  • .gitignore:22-32 — the FOOTGUN WARNING this issue proposes to make unnecessary
  • .github/workflows/ci.yml:228-276examples-gitignore-coverage, which
    covers the inverse property only

Metadata

Metadata

Assignees

No one assigned

    Labels

    tech-debtTechnical debttoolingEditor support, LSP, formatters

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions