Guardrails for 22 Docs Repos
How the sites are stitched into one website is in Running a Federated Docs Site, and what the repo has held over two years is in Two Years of a Knowledge Repo. This post is about the other side: the checks that decide what is allowed to reach those sites, and the commands that tell me the state of 22 repos without opening 22 terminals.
The short version: every guardrail that held was a command that prints a number. Every one that failed was a convention I meant to follow.
The premise that was wrong
The working assumption for two years was simple. A private repo keeps its contents private, and a p_ filename prefix keeps a notebook off the site. In September I checked both with an anonymous curl, and neither held.
- A private repo does not give you a private site. GitHub Pages serves a site to anyone, whatever the repo’s visibility. Every private repo in the fleet that had a Pages site returned
200to an unauthenticated request.gh repo view --json visibilitytells you about the repo and nothing about the site. p_was navigation, not a boundary. The sidebar ruleauto: "[0-9]*.ipynb"only lists numbered notebooks, so ap_page was missing from the menu. Butnbdev-docsstill rendered it and pushed it. It was live at its direct URL, listed insitemap.xml, and indexed by the site’s own search box.- The inverse was worse. A few notebooks with personal figures in them had ordinary numeric names, so they were not only published but linked in the sidebar.
The fix for the second point is one block in the shared _quarto.yml: a project.render list that excludes p_*.ipynb by glob. Now Quarto never renders the page at all. The first point has no setting. Anything that must stay private has to live somewhere that has no deploy workflow, and the documents that fell in that category moved to a separate private repo with no Pages site.
Stored outputs are published too
This was the leak that started it, and it is the least obvious one.
Quarto renders the outputs a notebook already holds. It does not run the notebook. So if a code cell once printed some numbers, and I later rewrote the cell to stop printing them, the old numbers are still in the .ipynb JSON under the new code, and they are still on the site. The source looked clean in review. The page did not.
Two rules came out of that:
- Clear outputs that are not the point. A concept notebook with
skip_exec: trueis never executed, so any output it carries is stale by definition. - Any scanner must read outputs as well as source. A
grepover the code cells would have passed the leaking notebook.
just scan: a secret scanner people will actually run
just scan walks all 22 submodules and reads file contents, not git metadata. It reports three counts per submodule:
| Count | Meaning |
|---|---|
| published | A hit in a file the site renders right now (a non-p_ .ipynb or .md). This is on the public web. |
| tracked | A hit in a file that is only in git. A smaller problem. |
| binary docs | PDFs, spreadsheets and databases. They cannot be scanned without a parser, so they are counted, not judged. |
It exits 1 on any published finding. --strict also fails on tracked ones, and --detail lists each hit.
What it looks for, by category: private key material, vendor tokens with known prefixes (cloud, Git hosting, chat, LLM APIs), password hashes, government ID numbers, long hex secrets next to words like token or api_key, credentials assigned as literals, and a column of five or more real email addresses (a user table, not a contact line). For notebooks it reads cell sources plus text outputs, and it skips image/* payloads. That skip is not only speed: megabytes of base64 plot data look like high-entropy secrets to a regex.
The false-positive problem decided whether it would be used
The first version of the credential rule reported 23 published findings. 22 were code. A docs fleet about Django, Stripe and Grafana is full of lines like these:
password = forms.CharField(widget=forms.PasswordInput)
api_key = settings.STRIPE_SECRET_KEYThe one real finding was a live API token, and it was invisible in that list. A scanner with 22 false alarms out of 23 is a scanner nobody reads, so the second version judges the value the pattern captured, not just the keyword:
def looks_secret(v):
if len(v) < 16: return False
if not re.fullmatch(r"[A-Za-z0-9_\-+/=.~]+", v): return False # an expression
if re.fullmatch(r"[A-Z0-9_]+", v): return False # ENV_VAR_NAME
if re.fullmatch(r"[A-Za-z_][\w.]*", v) and "." in v:return False # settings.API_KEY
if re.search(r"[*x]{4,}|\.{3,}", v): return False # already masked
classes = sum(bool(re.search(c, v)) for c in (r"[a-z]", r"[A-Z]", r"\d"))
return classes >= 3A real generated secret is a plain literal that mixes lower case, upper case and digits. A word, an expression, an environment variable name or a masked example does not. A doc that has to show a secret-shaped string on purpose marks that line with scan:allow.
The known limit is stated in the tool’s docs rather than hidden: an entropy test cannot catch a short password a human chose and wrote in prose. Chasing that would fire on every page that contains the word “password”. Those are found by reading.
Today the summary line is 22 submodules: 4 with findings, 17 clean, 1 without nbs, and every one of those findings is in the tracked or binary column. Zero published.
just nblint: a standard is a number per rule
The same month I wrote down a notebook standard: a title cell with # H1, a > description and correctly spelled skip directives, one ## section per cell, diagrams as SVG files, ASCII-only code, timezone-aware datetimes, no stale outputs, and an index page that links every public notebook. A standard on paper drifts. So just nblint turns it into a table, one row per rule, each tagged with the phase of the cleanup issue that drives it to zero.
The baseline on 2026-11-11 was taken over 677 notebooks in 20 nbdev submodules. Selected rows, before and now:
| Rule | Baseline (notebooks) | Now |
|---|---|---|
Plain ```mermaid fence (raw source on the site) |
15 | 0 |
Title cell has no # H1 |
3 | 0 |
| Title cell is a code cell | 19 | 0 |
Title cell has no > description |
11 | 0 |
Concept notebook without skip_showdoc |
11 | 0 |
| Non-ASCII characters in code cells | 24 | 0 |
Naive now() / utcnow() |
3 | 0 |
Filename with a space or & |
18 | 0 |
## cell without a trailing --- |
366 | 0 |
Braced {mermaid} not yet an SVG |
27 | 2 |
skip_exec notebook carrying outputs |
87 | 91 |
| Notebook over 3 MB | 29 | 29 |
The last two rows are deliberately left as a measured backlog rather than hidden. Stripping 1,700-odd stale outputs is a large, mechanical change of its own, and it was scoped out of this round.
By default nblint always exits 0: it measures, it does not gate. --strict turns it into a gate when a rule is at zero and should stay there.
Things the linter found that reading never did
- nbdev silently ignores misspelled directives.
Skip_exec,skip_docand similar typos were sitting in title cells, and nbdev treats an unknown key as nothing. No warning, just a notebook that executes or documents when it should not. That became its own rule, which flags any title-cell key that looks like a skip directive but is not one exactly. - A title cell that starts with
---breaks the whole repo. Quarto parses it as YAML front matter, andnbdev-testfails every notebook, not just that one. - The linter’s own test fixtures tripped it. A fixture that contains a non-ASCII character or a naive
now()gets flagged in the linter’s own notebook. The fixtures now build those strings at runtime. - Renames rot links quietly. A follow-up audit of this blog found 69 of 93 internal links to the docs sites were dead, from renamed sites, moved pages and slugs that drop their number prefix. Each was replaced only with a URL that returned 200, and a re-audit found zero dead links.
One walker for 22 submodules
The status commands came first, and they are what make the other two cheap to run. Every fleet recipe in the justfile (status, gss, update, sync, upload, push, copy_quarto, scan, nblint) is now one line that calls a fleet command in my nbdevAuto package. One walker backs all of them, so they share one output style and one rule:
A submodule that has nothing to report does not get a line. It gets counted. On a fleet with one dirty repo, just upload prints a single summary like 21 submodules: 1 uploaded, 19 clean, 1 without nbs instead of 21 lines that all say “nothing to do”. The noise I removed is what lets the one line that matters be seen.
| Command | Question it answers |
|---|---|
just status / just gss |
Which submodules are dirty, and what changed in each |
just report |
Dirty, behind or ahead, plus CI and Pages state |
just ci |
Per submodule: last CI run, Pages deploy, Pages build, main sha |
just scan |
Is anything secret or personal on the public web |
just nblint |
How far is each rule from zero |
Moving the loops into Python took the justfile from 406 to 321 lines with no loop logic left in it. Two things stay in bash on purpose: init, which runs on a fresh clone before Python is installed, and a git-only fallback for report. That fallback matters: with a working environment, report --offline takes about 0.15 s, while the pure bash version has to fetch every remote and took about 54 s.
Takeaway
| Guardrail | What it replaced | What it prints |
|---|---|---|
project.render excludes p_* |
A sidebar rule that only hid the link | Nothing to check: the page is never built |
| Separate private repo, no deploy workflow | “It is a private repo” | Nothing: there is no site |
just scan |
Remembering not to paste secrets | Published / tracked / binary per submodule, exit 1 on published |
just nblint |
A standard written in a docs file | Notebooks and items per rule, per phase |
fleet walker |
22 terminals and git status |
One summary line, plus a line only for submodules that need attention |
Repo visibility, filename conventions and code review all felt like guardrails, and the anonymous curl showed that none of them were. The checks that held are the ones that print a number, and every new rule I write down now gets a row in one of these tables.