Quellcode durchsuchen

tests: one data-driven guard suite for lesson pages, ten per-lesson files removed (#525) (#530)

* tests: one data-driven guard suite for every lesson page (#525)

Generic checks run on all 58 lesson pages (no em dash, address allowlist,
secret patterns, honest status banner, claims register statuses, link and
anchor targets, glossary anchors, registration, sibling links, not-run
marks). Per-lesson requirements of ten lessons are data rows in
tests/lesson_guard_data.py. The old per-lesson files are removed in the
next commit.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* tests: remove ten per-lesson guard files now covered by test_lesson_guards (#525)

Each deleted assertion is a generic check or a data row in
tests/lesson_guard_data.py; the three tests that run external tools
(qemu-img, openssl, ansible-playbook) moved into the suite unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* tests: lesson guards check every identifier kind, the banner's own date and unrun statements anywhere (#525)

The identifier check now applies every pattern kind of the repo gate
(Azure resource paths and sign-in URLs, AWS ARNs, GCP projects). The
banner must be dated inside the banner text. A statement that something
was not run anywhere on a page needs an unrun mark. Each has a negative
case; three pages name their own marks as data.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
ChiefGyk3D vor 4 Wochen
Ursprung
Commit
8893cee90f

+ 443 - 0
tests/lesson_guard_data.py

@@ -0,0 +1,443 @@
+# SPDX-License-Identifier: Apache-2.0
+"""Data for tests/test_lesson_guards.py (issue #525): the shared defaults, then one entry per lesson page.
+
+An entry is {"config": {...}, "rows": [...]}. Both are optional: a page with no entry gets the defaults only.
+
+config keys (all optional):
+  status_words        EXACT list of words a claims register status cell may contain. It replaces the shared
+                      vocabulary, so use it where the old per-lesson file had a narrower set.
+  status_extra        words added to the shared vocabulary for one page (a status the page really uses).
+  addresses_allow     EXACT list of address regexes the page may contain. It replaces the shared defaults.
+  addresses_extra     address-shaped strings added to the shared defaults (a version number, a documented lab net).
+  addresses_require   addresses that must appear (so the address guard cannot go vacuous).
+  min_register_rows, min_links, min_glossary_rows   thresholds; 0 glossary rows means the page has no glossary terms.
+  nav_contains        text the page's _nav.yaml line must carry (its status and subgroup).
+  nav_places_skip     navigation files that do not list the page, with the reason in a comment.
+  unrun_marks_extra   extra words that count as the page's mark for what was not run (the page names its own).
+  must_link, must_link_prefix   pages (or page-name prefixes) the lesson must link, as links, never as plain text.
+
+A row is {"id", ...assertions}; the assertion keys are documented on `check_row` in test_lesson_guards.py. A row with
+"start"/"end" looks only at the text between those two strings.
+"""
+
+DEFAULTS = {
+    "status_words": ("Read", "Observed", "Run", "General knowledge", "**est.**", "Not read", "Not run", "Not verified", "Constructed", "Secondary", "Page read", "Search summary"),
+    # documented placeholder ranges (RFC 5737), loopback, the unspecified address and the cloud metadata address
+    "addresses_default": (r"192\.0\.2\.\d+", r"198\.51\.100\.\d+", r"203\.0\.113\.\d+", r"127\.\d+\.\d+\.\d+", r"0\.0\.0\.0", r"169\.254\.169\.254"),
+    "min_register_rows": 1,
+    "min_links": 1,
+    "min_glossary_rows": 1,
+}
+
+# Pages whose _nav.yaml entry carries a `status` but that have no `## Claims register`: the cloud-provider pages, the
+# telemetry pages and a few runbooks. They are not lessons of this form, so the discovery rule leaves them out. The
+# list is explicit so that a lesson which LOSES its register is a named failure and not a silent drop from the suite.
+NO_REGISTER = (
+    "Build-Your-Own-Mini-SOC",
+    "Cloud-Telemetry-What-and-Why",
+    "DMZ-Hardening-Checklist",
+    "Detection-and-Monitoring-Wazuh-and-the-Landscape",
+    "Multiple-Sites-and-Identity",
+    "Provider-AWS-Account-Preparation",
+    "Provider-AWS-Cost-Lesson",
+    "Provider-AWS-The-Same-Four-Pieces",
+    "Provider-Azure-Account-Preparation",
+    "Provider-Azure-Cost-Lesson",
+    "Provider-Azure-The-Same-Four-Pieces",
+    "Provider-GCP-Account-Preparation",
+    "Provider-GCP-Cost-Lesson",
+    "Provider-GCP-The-Same-Four-Pieces",
+    "Reading-a-Dashboard-as-an-Operator",
+    "Stage-2-Home-Side-Runbook",
+    "Telemetry-Crosses-the-Trust-Boundary",
+    "Why-Not-Private-Droplets-Yet",
+    "Why-the-Clouds-Differ",
+)
+
+VM = "Virtual-Machines-Hypervisors-Desktop-and-Datacenter-Options"
+CRON = "Cron-Systemd-Timers-and-Init-Scripts-vs-Systemd"
+ANSIBLE = "Ansible-Configuration-Management-Versus-Provisioning"
+DFIR = "DFIR-Toolkits-and-Live-Triage-SIFT-Velociraptor-KAPE-and-the-Incident-Response-Workflow"
+DISK_ENC = "Disk-and-File-Encryption-VeraCrypt-TrueCrypt-History-BitLocker-FileVault-and-LUKS"
+DISK_FOR = "Disk-Forensics-with-Autopsy-and-The-Sleuth-Kit"
+HSM = "Hardware-Security-Modules-What-They-Are-and-Building-Your-Own-with-pico2hsm"
+MEMORY = "Memory-Forensics-Acquiring-RAM-and-Analyzing-It-with-Volatility-3"
+NETLOG = "Network-Log-and-Timeline-Forensics-Packet-Captures-Logs-and-Plaso"
+FIRMWARE = "Open-Firmware-and-Trustworthy-Hardware-coreboot-Heads-Nitrokey-and-Vendors-That-Ship-the-Intel-ME-Disabled"
+
+DRAFT = 'status: "draft"'
+FORENSICS = 'subgroup: "Digital forensics"'
+BRIDGE_FORBID = r"-(nic|netdev|net)\s+(bridge|tap)|\bbridge=|--network\s+bridged|nic\d?\s+bridged"
+
+PAGES: dict[str, dict] = {
+    # ---- pages that have no per-lesson file: the generic checks, plus the statuses they really use ----------------
+    "Attack-Surface-List-Shrink-Measure": {"config": {"status_extra": ("Searched", "est."), "unrun_marks_extra": ("est.",), "min_glossary_rows": 0}},
+    "Attack-Surface-Map-Layer-by-Layer": {"config": {"unrun_marks_extra": ("not tested on a real droplet",), "status_extra": ("Carried over",), "min_glossary_rows": 0}},
+    "Cryptography-Fundamentals-Symmetric-Asymmetric-Hashing-Certificates-and-Keys": {"config": {"status_extra": ("Listing read", "Title and header read")}},
+    "Deception-and-Honeypots-Cloud-Cowrie-Weekend": {"config": {"status_extra": ("The ISC's claim",), "min_glossary_rows": 0}},
+    # the Reading-Order page lists the cloud-sensor path of the deception lessons, not this introduction
+    "Deception-and-Honeypots-What-Deception-Is": {"config": {"nav_places_skip": ("Reading-Order.md",)}},
+    "Environments-and-Promotion-Dev-Staging-Production": {"config": {"status_extra": ("**Not designed**",)}},
+    "Grafana-Basics-From-a-Blank-Page": {"config": {"status_extra": ("Written from reading",)}},
+    "Hardware-Security-Keys-YubiKey-Nitrokey-Smart-Cards-and-PIV": {"config": {"status_extra": ("My opinion",)}},
+    "Kubernetes-for-Beginners-What-It-Adds-Over-Docker-and-Compose": {"config": {"status_extra": ("Quoted from", "Repeated from")}},
+    "Linux-for-Enterprise-Beginners": {"config": {"status_extra": ("Matches the vendor pages", "Not re-verified")}},
+    "Privacy-vs-Security-Blinds-and-Locks-Physical-Security-and-Monero": {"config": {"status_extra": ("Nothing run",)}},
+    "Radio-Off-Grid-Communication-LoRa-Meshtastic-Reticulum-Ham-and-SIGINT": {"config": {"status_extra": ("Stated by the maintainer",)}},
+    "Static-vs-Dynamic-Sites-Hugo-and-WordPress-and-Recon": {"config": {"status_extra": ("**Est.**", "His words", "**Unverified.**")}},
+    "The-DMZ-and-Hardening-a-Host-That-Faces-the-Internet": {"config": {"unrun_marks_extra": ("**unverified**",), "status_extra": ("Recommendation", "Interpretation")}},
+    "Wazuh-SIEM-and-Data-Pipelines": {"config": {"status_extra": ("**UNVERIFIED**",)}},
+    # version numbers and lab networks that look like addresses
+    "Hands-On-Whonix-and-Qubes-OS-Gateway-Split-Compartments-Disposables-and-Policy-Prompts": {"config": {"addresses_extra": (r"10\.152\.152\.\d+", r"18\.2\.4\.2", r"255\.255\.192\.0")}},
+    "How-I2P-Works-Tunnels-Garlic-Routing-and-the-Network-Database": {"config": {"addresses_extra": (r"0\.9\.7\.1",)}},
+    "Lab-Publish-a-Web-Server-as-a-Tor-Onion-Service-and-an-I2P-Site-Time-Boxed-and-Defensive": {"config": {"addresses_extra": (r"0\.4\.8\.10", r"0\.4\.9\.14")}},
+    "Wallets-and-Key-Custody-Hot-and-Cold-Hardware-Wallets-Recovery-Shamir-and-Multisig": {"config": {"addresses_extra": (r"1\.14\.1\.0",)}},
+    # ---- Ansible ------------------------------------------------------------------------------------------------
+    ANSIBLE: {
+        "config": {
+            "status_words": ("Read", "Observed", "**est.**"),
+            "addresses_allow": (r"127\.0\.0\.1",),
+            "min_register_rows": 20,
+            "min_links": 8,
+            "min_glossary_rows": 5,
+            "nav_contains": (DRAFT,),
+        },
+        "rows": [
+            {"id": "banner", "startswith": "# Ansible: configuration management versus provisioning", "contains": ["Status: unverified draft", "2026-11-07", "**Not run:**", "ansible-core 2.22.0"]},
+            {
+                "id": "lab-commands-stay-on-the-local-machine",
+                "code": {
+                    "tags": ["bash", "ini"],
+                    "require": ["ansible_connection=local", "ansible-playbook"],
+                    "forbid": r"\bansible_host=|\bansible_ssh_|\bssh\s+\S+@",
+                    "bite_bad": ["web ansible_host=203.0.113.9", "ssh admin@box"],
+                    "bite_good": ["localhost ansible_connection=local"],
+                },
+            },
+            {"id": "check-mode-before-the-real-repair-run", "start": "### Exercise 4", "end": "### Exercise 5", "order_before_last": [("--check --diff", "ansible-playbook -i inventory.ini site.yml\n")]},
+            {"id": "unverified-claims-are-marked-in-the-body", "count_at_least": {"est.": 10}},
+            # test_ansible_playbook_is_idempotent_and_the_bad_task_is_not (needs ansible-playbook) stays code in the suite
+        ],
+    },
+    # ---- Cron, timers, init scripts -----------------------------------------------------------------------------------
+    CRON: {
+        "config": {
+            "status_words": ("Read", "Run", "Observed", "**est.**", "Statement of opinion"),
+            "addresses_allow": (),
+            "min_register_rows": 15,
+            "min_links": 5,
+            "min_glossary_rows": 7,
+            "nav_contains": (DRAFT,),
+        },
+        "rows": [
+            {"id": "banner", "startswith": "# Cron, systemd timers, and init scripts versus systemd", "contains": ["Status: unverified draft", "I did not start a timer", "did not edit a crontab", "2026-11-07", "Not verified, plainly"]},
+            {"id": "lessons-that-mention-cron-link-this-one", "inbound_all": ["Terminal-and-Your-First-Script", "Linux-for-Enterprise-Beginners", "First-Hour-on-a-New-System-Updates-and-Baseline"]},
+            {
+                "id": "translation-table-weekly-and-the-day-rule",
+                "contains": ["`weekly` means Monday at midnight in systemd", "`@weekly` | `Sun *-*-* 00:00`"],
+                "contains_any": ["the 1st and 15th **or** Fridays", "the 1st and 15th **and** on every Friday"],
+            },
+            {
+                "id": "distro-table-dated-and-unread-edges-marked",
+                "start": "## Is cron still installed? What I checked",
+                "end": "## Init scripts versus systemd",
+                "contains": ["2026-11-07", "Debian", "Ubuntu", "Rocky", "Fedora", "Arch", "openSUSE"],
+                "count_at_least": {"**est.**": 4},
+            },
+            {
+                "id": "exercises-never-use-crontab-r",
+                "contains": ["crontab -r"],  # the warning about it must stay in the page
+                "code": {"tags": ["bash"], "require": ["crontab"], "forbid": r"crontab -r", "bite_bad": ["crontab -r"], "bite_good": ["crontab -l"]},
+            },
+        ],
+    },
+    # ---- DFIR toolkits ----------------------------------------------------------------------------------------------
+    DFIR: {
+        "config": {
+            "status_words": ("Read", "Run", "Page read", "**est.**"),
+            "addresses_allow": (),
+            "min_register_rows": 20,
+            "min_links": 8,
+            "min_glossary_rows": 5,
+            "nav_contains": (DRAFT, FORENSICS),
+            "must_link": ("Build-Your-Own-Mini-SOC", "Logs-SIEM-and-Detection-Basics", "Backups-Recovery-and-Patching", "Careers-Roles-and-What-to-Learn-Next"),
+        },
+        "rows": [
+            {"id": "banner", "startswith": "# DFIR toolkits and live triage", "contains": ["Status: unverified draft", "**Not run:**", "2026-11-07", "Not verified, plainly"]},
+            {
+                "id": "toolkit-table-names-every-tool-and-closed-ones-are-marked",
+                "start": "## The toolkits at a glance",
+                "end": "## Live triage and dead-box imaging",
+                "contains": ["SIFT Workstation", "CAINE", "Velociraptor", "KAPE", "FTK Imager", "plaso", "AGPL-3.0", "Apache-2.0", "2026-11-07"],
+                "count_at_least": {"**not open source**": 2},
+            },
+            {
+                "id": "nist-account-names-both-revisions",
+                "start": "## An incident response workflow, and where forensics fits",
+                "end": "## Mobile and cloud forensics",
+                "contains_ci": ["Revision 2", "Revision 3", "April 2025", "Govern", "lessons learned"],
+            },
+            {
+                "id": "certifications-carry-no-prices-and-no-affiliate-links",
+                "start": "## Training and certifications",
+                "end": "## Free exercise",
+                "regex_absent": [r"[$€£]\s?\d|\bUSD\b"],
+                "absent": ["http", "ref="],
+                "contains": ["GCFE", "GCFA"],
+            },
+            {
+                "id": "exercise-collects-only-into-the-learners-folder",
+                "code": {
+                    "tags": ["bash"],
+                    "require": ["collect.sh", "sha256sum -c", "mkdir -p ~/triage-lab"],
+                    "forbid": r"crontab -r|sudo rm|>\s*/(etc|usr|var|bin)/",
+                    "bite_bad": ["crontab -r", "sudo rm -rf x", "echo x > /etc/passwd"],
+                    "bite_good": ["echo x > ~/triage-lab/out"],
+                },
+            },
+        ],
+    },
+    # ---- Disk and file encryption --------------------------------------------------------------------------------------
+    DISK_ENC: {
+        "config": {
+            "status_words": ("Read", "Observed", "**est.**"),
+            "addresses_allow": (),
+            "min_register_rows": 20,
+            "min_links": 8,
+            "min_glossary_rows": 10,
+            "nav_contains": (DRAFT,),
+        },
+        "rows": [
+            {"id": "banner", "startswith": "# Disk and file encryption", "contains": ["Status: unverified draft", "**Not run:**", "2026-11-07", "Not verified, plainly"]},
+            {"id": "not-run-list-names-the-untried-features", "start": "**Not run:**", "end": "Vendor and project statements", "contains": ["a hidden volume", "a keyfile", "BitLocker", "FileVault"]},
+            {"id": "no-unfinished-placeholder", "absent": ["RESULTS_", "TODO", "@@"]},
+            {
+                "id": "every-password-in-a-command-is-a-labeled-placeholder",
+                "contains": ["Never type a password you use anywhere real"],
+                "code": {
+                    "tags": ["bash"],
+                    # a literal password handed to the tool (-p 'x', --new-password='x', PW='x') that is not marked PLACEHOLDER
+                    "forbid": r"(?:\s-p\s+|--new-password=|\bPW=)'(?![^']*PLACEHOLDER)[^']*'",
+                    "count_at_least": {r"(?:\s-p\s+|--new-password=|\bPW=)'[^']*'": 4},
+                    "bite_bad": ["veracrypt -C x -p 'hunter2'"],
+                    "bite_good": ["veracrypt -C x -p 'Wrong-PLACEHOLDER-2'"],
+                },
+            },
+            {
+                "id": "truecrypt-history-dated-and-quotes-the-notice",
+                "start": "## From TrueCrypt to VeraCrypt: a dated history",
+                "end": "## Where it fits",
+                "contains": [
+                    "2014-04-14", "2014-05-28", "2014-09-04", "2014-12-30", "2015-04-02", "2015-08-05", "2016-10-17", "2023-10-01", "2026-06-09",
+                    "WARNING: Using TrueCrypt is not secure as it may contain unfixed security issues",
+                    "two High, none Medium, one Low, one Undetermined",
+                    "8 critical, 3 medium and 15 low",
+                    "(secondary)",
+                ],
+            },
+            {
+                "id": "hidden-volumes-with-their-honest-limits",
+                "start": "### Hidden volumes and plausible deniability, with the limits",
+                "end": "### Use across",
+                "contains": ["several points over time", "wear-leveling", "TRIM", "1.18a", "must recreate both the outer and hidden volumes", "legal"],
+            },
+            {"id": "platform-tools-and-comparison", "start": "## Full-disk encryption by platform", "end": "## Three layers", "contains": ["BitLocker", "FileVault", "LUKS", "XTS", "recovery key", "TPM"]},
+            {"id": "defaults-quoted-match-the-documentation", "contains": ["500,000 iterations", "200,000", "416 MiB", "6 passes"]},
+        ],
+    },
+    # ---- Disk forensics ---------------------------------------------------------------------------------------------
+    DISK_FOR: {
+        "config": {
+            "status_words": ("Read", "Observed", "Search summary only", "**est.**"),
+            "addresses_allow": (),
+            "min_register_rows": 25,
+            "min_glossary_rows": 4,
+            "nav_contains": (DRAFT, FORENSICS),
+            "must_link": ("Hashing-Encryption-and-Keys", VM, "Terminal-and-Your-First-Script"),
+            # the siblings are on main: each is a link to a page that exists (it was plain text before)
+            "must_link_prefix": ("Digital-Forensics-Foundations", "Memory-Forensics", "Network-Log-and-Timeline-Forensics", "DFIR-Toolkits"),
+        },
+        "rows": [
+            {"id": "banner", "startswith": "# Disk forensics with Autopsy and The Sleuth Kit", "contains": ["Status: unverified draft", "Autopsy itself was not installed or started", "**Not run:**", "2026-11-07", "Not verified, plainly"]},
+            {
+                "id": "authorization-rule-is-stated-up-front",
+                "order": [("Examine only your own devices or data you are explicitly authorized to examine", "## What you will be able to do")],
+                "contains": ["not legal advice"],
+            },
+            {
+                "id": "hash-step-before-the-examination-commands",
+                "order": [("sha256sum lab.dd > lab.dd.sha256", "mmls lab.dd\n   fsstat")],
+                "regex_present": [r"`[0-9a-f]{64}`|[0-9a-f]{64}  lab\.dd"],
+            },
+            {"id": "versions-and-licenses-are-dated", "contains": ["4.23.1", "4.15.0", "2026-05-07", "2026-04-15", "Apache License", "Common Public License", "October 2023"]},
+        ],
+    },
+    # ---- Hardware security modules ----------------------------------------------------------------------------------------
+    HSM: {
+        "config": {
+            "status_words": ("Read", "Observed", "General knowledge", "**est.**"),
+            "min_register_rows": 20,
+            "min_links": 6,
+            "min_glossary_rows": 5,
+            "nav_contains": (DRAFT,),
+        },
+        "rows": [
+            {"id": "banner", "startswith": "# Hardware security modules", "contains": ["Status: unverified draft", "**Not run:**", "2026-11-07", "no Pico 2 was available"]},
+            {"id": "part-b-is-marked-untested", "contains": ["Part B: the same on a Pico 2 (UNTESTED)", "**Untested.**"]},
+            {"id": "maintainer-checks-exist", "start": "## For the maintainer: checks to run when you build it", "end": "## Checkpoint", "numbered_items_min": 10},
+            # the three values the project's own docs publish as sample PINs
+            {"id": "no-published-sample-pins", "absent": ["648219", "3537363231383830", "57621880"]},
+            {"id": "projects-own-limits-are-quoted", "contains": ["not a certified secure element", "Never deploy either: the development storage key is public.", "A4", "RP2350-E24"]},
+            # test_hsm_part_a_signs_verifies_and_fails_on_a_changed_message (needs openssl) stays code in the suite
+        ],
+    },
+    # ---- Memory forensics ------------------------------------------------------------------------------------------------
+    MEMORY: {
+        "config": {
+            "status_words": ("Read", "Observed", "General knowledge", "**est.**"),
+            "addresses_allow": (r"127\.0\.0\.1",),
+            "addresses_require": ("127.0.0.1",),
+            "min_register_rows": 20,
+            "min_links": 4,
+            "min_glossary_rows": 4,
+            "nav_contains": (DRAFT, FORENSICS),
+            # the siblings are on main now: each is a link to a page that exists (they were plain text before)
+            "must_link_prefix": ("Digital-Forensics-Foundations", "Disk-Forensics", "Network-Log-and-Timeline-Forensics", "DFIR-Toolkits", "Device-Firmware-Security", "Open-Firmware"),
+        },
+        "rows": [
+            {"id": "banner", "startswith": "# Memory forensics: acquiring RAM", "contains": ["Status: unverified draft", "**Not run:**", "2026-11-07", "Volatility 3 2.28.2"]},
+            {"id": "callsign-and-machine-names-are-placeholders", "contains": ["N0TST", r"local-hostname: lab\n"]},
+            {
+                "id": "guest-never-bridged-onto-a-real-network",
+                "code": {
+                    "tags": ["bash"],
+                    "require": ["-nic user", "hostfwd=tcp:127.0.0.1"],
+                    "forbid": r"-(nic|netdev|net)\s+(bridge|tap)|\bbridge=",
+                    "bite_bad": ["qemu-system-x86_64 -nic bridge,br=br0"],
+                    "bite_good": ["qemu-system-x86_64 -nic user,model=virtio-net-pci"],
+                },
+            },
+            {"id": "checksum-before-first-boot", "order": [("sha512sum -c sums", "qemu-system-x86_64 -accel kvm")], "contains": ["do not boot the image"]},
+            {"id": "license-and-version-dated", "contains": ["Volatility Software License, Version 1.0", "2.28.2", "2026-09-17"]},
+            {"id": "plugins-it-ran", "contains": ["linux.pslist.PsList", "linux.psscan.PsScan", "linux.sockstat.Sockstat", "linux.malware.malfind.Malfind", "windows.psscan.PsScan", "windows.netscan.NetScan"]},
+        ],
+    },
+    # ---- Network, log and timeline forensics -------------------------------------------------------------------------------
+    NETLOG: {
+        "config": {
+            "status_words": ("Read", "Run", "Observed", "**est.**"),
+            "addresses_allow": (r"10\.89\.0\.\d{1,3}", r"0\.0\.0\.0"),  # the lab container network
+            "min_register_rows": 15,
+            "min_links": 6,
+            "min_glossary_rows": 5,
+            "nav_contains": (DRAFT, FORENSICS),
+        },
+        "rows": [
+            {"id": "banner", "startswith": "# Network, log and timeline forensics", "contains": ["Status: unverified draft", "2026-11-07", "Not verified, plainly", "What I ran and what failed"]},
+            {"id": "in-page-anchors-were-collected", "regex_count_at_least": {r"\]\(#[a-z0-9-]+\)": 1}},
+            {"id": "invented-lab-password-is-marked-invented", "contains": ["hunter2-lab", "invented"]},
+            {"id": "time-zone-lesson-names-both-runs-and-the-offset", "contains": ["--timezone America/New_York", "2026-11-07T10:49:52+00:00", "2026-11-07T15:49:52+00:00", "7 minutes 2 seconds"]},
+            {"id": "plaso-facts-dated-with-real-parser-names", "contains": ["20261027", "Apache-2.0", "text/apache_access", "text/syslog_traditional"]},
+            {"id": "law-section-and-own-network-only", "contains": ["not legal advice"], "contains_any": ["own computer", "container network you create"]},
+        ],
+    },
+    # ---- Open firmware -------------------------------------------------------------------------------------------------
+    FIRMWARE: {
+        "config": {
+            "status_words": ("Read", "Observed", "General knowledge", "**est.**", "**not verified**"),
+            "addresses_allow": (),
+            "min_register_rows": 35,
+            "min_links": 5,
+            "min_glossary_rows": 6,
+            "nav_contains": (DRAFT,),
+        },
+        "rows": [
+            {"id": "banner", "startswith": "# Open firmware and trustworthy hardware", "contains": ["> **Status: unverified draft.", "Nothing was flashed", "**Not run:**", "2026-11-07", "Not verified, plainly"]},
+            {"id": "no-en-dash", "absent": ["–"]},
+            {"id": "no-affiliate-links", "urls_min": 20, "url_forbid": r"[?&](ref|aff|affiliate|utm_[a-z]+|tag|partner)="},
+            {
+                "id": "no-flashing-or-write-commands-in-any-code-block",
+                "code": {
+                    "require": ["curl", "fwupdmgr"],
+                    "forbid": r"\bsudo\b|\bflashrom\b|\bifdtool\b|\bme_cleaner\b|\bnvramtool\b|\bdd\b|\bchmod\b|>\s*/(?:sys|dev|boot)",
+                    "ignorecase": True,
+                    "bite_bad": ["sudo flashrom -p internal -w rom.bin", "python me_cleaner.py -S image.bin", "echo 1 > /sys/class/x"],
+                    "bite_good": ["cat /sys/class/tpm/tpm0/tpm_version_major"],
+                },
+            },
+            {
+                "id": "each-vendor-has-a-firmware-and-an-me-line",
+                "vendor_sections": {
+                    "Novacustom": ["Firmware", "ME"],
+                    "System76": ["Firmware", "ME"],
+                    "Purism": ["Firmware", "ME"],
+                    "Tuxedo": ["ME"],
+                    "Tuxedo Computers": ["I could not verify a claim"],
+                },
+            },
+            {"id": "me-words-and-dasharo-modes-are-named", "contains": ["**Absent**", "**Neutralized**", "**Soft-disabled**", "**HAP-disabled**", "Enabled", "Disabled (Soft)", "Disabled (HAP)"]},
+            {"id": "register-is-dated", "count_at_least": {"2026-11-07": 8}},
+            {"id": "register-names-every-vendor", "start": "## Claims register", "contains": ["Novacustom", "System76", "Purism", "Tuxedo"]},
+            {"id": "heads-key-table-matches-the-prerequisites-wording", "contains": ["Heads does NOT support FIDO2 or U2F", "OpenPGP only", "YubiKey 5 Series", "Nitrokey Pro 2", "Nitrokey Storage 2", "Nitrokey 3", "Librem Key"]},
+            {
+                "id": "page-ends-by-linking-the-firmware-and-hardware-keys-lessons",
+                "start": "## Where this goes next",
+                "links_in_scope": ["Device-Firmware-Security-Intel-ME-AMD-PSP-MINIX-and-Kernel-Design", "Hardware-Security-Keys-YubiKey-Nitrokey-Smart-Cards-and-PIV"],
+                "absent": ["no link"],
+            },
+            {"id": "no-unwritten-page-wording", "absent": ["not written yet"], "contains": ["Hardware-Security-Keys-YubiKey-Nitrokey-Smart-Cards-and-PIV.md"]},
+            {
+                "id": "tuxedo-is-a-dated-user-selectable-option-on-one-model",
+                "vendor_sections": {"Tuxedo Computers": ["2018-03-14", "InfinityBook Pro 13", "TUXEDO-disables-Intels-Management-Engine.tuxedo"]},
+            },
+            {
+                "id": "tuxedo-wording-pin",
+                "absent": ["Ask Tuxedo in writing"],
+                "absent_except": [("ships with the ME disabled", 'not "ships with the ME disabled"')],
+                "register_row": {"select": ["press release", "Tuxedo"], "first_has": ["2018-03-14"], "second_has": ["TUXEDO-disables"]},
+            },
+        ],
+    },
+    # ---- Virtual machines and hypervisors -------------------------------------------------------------------------------------
+    VM: {
+        "config": {
+            "status_words": ("Read", "Observed", "Page read", "General knowledge", "**est.**"),
+            "addresses_allow": (r"127\.0\.0\.1",),
+            "addresses_require": ("127.0.0.1",),
+            "min_register_rows": 25,
+            "min_links": 8,
+            "min_glossary_rows": 5,
+            "nav_contains": (DRAFT,),
+        },
+        "rows": [
+            {"id": "banner", "startswith": "# Virtual machines for beginners", "contains": ["Status: unverified draft", "no hypervisor was installed and no guest was booted", "**Not run:**", "2026-10-31", "Not verified, plainly"]},
+            {"id": "pages-that-assume-a-vm-link-the-lesson", "inbound_min": 4},
+            {
+                "id": "lab-commands-never-bridge-the-guest-onto-a-real-network",
+                "code": {
+                    "tags": ["bash"],
+                    "require": ["qemu-system-x86_64", "-nic user"],
+                    "forbid": BRIDGE_FORBID,
+                    "bite_bad": ["qemu-system-x86_64 -nic bridge,br=br0", "qemu-system-x86_64 -netdev tap,id=n0"],
+                    "bite_good": ["qemu-system-x86_64 -nic user,model=virtio-net-pci"],
+                },
+            },
+            {
+                "id": "safety-rule-names-the-three-core-steps",
+                "start": "## The safety rule for malware and recon labs",
+                "end": "## Free path",
+                "contains": ["Isolate the network first", "Snapshot a clean state first", "Never bridge a hostile VM onto your home LAN"],
+            },
+            {"id": "checksum-before-first-boot", "order": [("sha256sum -c", "qemu-system-x86_64 -accel kvm")], "contains": ["do not boot an image that fails its check"], "regex_present": [r"`[0-9a-f]{64}`"]},
+            {
+                "id": "vmware-account-dated-with-vendor-and-news-sources",
+                "start": "## VMware after Broadcom: a dated account",
+                "end": "## The bigger options",
+                "contains": ["2023-11-22", "2023-12-11", "May 2024", "2024-11-11", "2025-03-10", "2025-04-10", "BBC News", "Ars Technica", "release notes", "**est.**", "Read"],
+                "contains_ci": ["not verified"],
+            },
+            {"id": "apple-options-from-apples-own-pages", "contains": ["Virtualization framework", "macOS 11.0", "`container`", "macOS 26"]},
+            # test_vm_exercise_3_runs_and_the_snapshot_round_trips (needs qemu-img) stays code in the suite
+        ],
+    },
+}

+ 0 - 146
tests/test_ansible_lesson.py

@@ -1,146 +0,0 @@
-# SPDX-License-Identifier: Apache-2.0
-"""The Ansible lesson: it is registered, honest about what was run, local-only, and its playbook really is idempotent.
-
-docs/wiki/Ansible-Configuration-Management-Versus-Provisioning.md teaches a playbook run twice. A broken link, a
-missing registration, a remote target in a lab command, a real address, or a claim with no status would each teach
-the wrong thing. The run test needs ansible-playbook and is skipped where it is absent.
-"""
-
-import re
-import shutil
-import subprocess
-import textwrap
-from pathlib import Path
-
-import pytest
-
-ROOT = Path(__file__).resolve().parent.parent
-WIKI = ROOT / "docs" / "wiki"
-NAME = "Ansible-Configuration-Management-Versus-Provisioning"
-PAGE = WIKI / f"{NAME}.md"
-FENCE = re.compile(r"^[ ]*```(\w*)\n(.*?)^[ ]*```$", re.MULTILINE | re.DOTALL)
-LINK = re.compile(r"\]\(([A-Za-z0-9_-]+)\.md(?:#[^)]*)?\)")
-ADDR = re.compile(r"\b(?:\d{1,3}\.){3}\d{1,3}\b")
-STATUS_WORDS = ("Read", "Observed", "**est.**")
-RECAP = re.compile(r"ok=(\d+)\s+changed=(\d+)")
-
-
-def text() -> str:
-    return PAGE.read_text(encoding="utf-8")
-
-
-def blocks(tag: str) -> list[str]:
-    return [textwrap.dedent(b) for t, b in FENCE.findall(text()) if t == tag]
-
-
-def register_rows(body: str) -> list[list[str]]:
-    reg = body.split("## Claims register")[1]
-    rows = [line for line in reg.splitlines() if line.startswith("|") and not line.startswith("|---")]
-    return [[c.strip() for c in r.strip("|").split("|")] for r in rows[1:]]
-
-
-def rows_missing_status(body: str) -> list[str]:
-    return [r[0] for r in register_rows(body) if not any(w in r[-1] for w in STATUS_WORDS)]
-
-
-def remote_targets(commands: str) -> list[str]:
-    """Lines that would aim a lab command at a machine other than the local one."""
-    return [l for l in commands.splitlines() if re.search(r"\bansible_host=|\bansible_ssh_|\bssh\s+\S+@", l)]
-
-
-def test_the_page_exists_and_says_what_was_and_was_not_run():
-    body = text()
-    assert body.startswith("# Ansible: configuration management versus provisioning")
-    assert "Status: unverified draft" in body
-    assert "2026-11-07" in body and "**Not run:**" in body
-    assert "ansible-core 2.22.0" in body
-
-
-def test_every_linked_wiki_page_exists():
-    links = set(LINK.findall(text()))
-    assert len(links) >= 8, "the guard collected too few links"
-    missing = sorted(t for t in links if not (WIKI / f"{t}.md").exists())
-    assert not missing, missing
-
-
-def test_the_lesson_is_registered_everywhere():
-    nav = (WIKI / "_nav.yaml").read_text(encoding="utf-8")
-    assert f"page: {NAME}," in nav and 'status: "draft"' in nav.split(f"page: {NAME},")[1].split("\n")[0]
-    for special in ("Contents.md", "_Sidebar.md", "Reading-Order.md"):
-        assert f"{NAME}.md" in (WIKI / special).read_text(encoding="utf-8"), special
-    rows = [l for l in (WIKI / "Glossary.md").read_text(encoding="utf-8").splitlines() if f"{NAME}.md" in l]
-    assert len(rows) >= 5, "expected glossary rows for the new terms"
-
-
-def test_glossary_rows_point_at_real_headings():
-    heads = {re.sub(r"[^a-z0-9-]", "", re.sub(r"[^a-z0-9 -]", "", h.lower()).strip().replace(" ", "-")) for h in re.findall(r"^#+ (.+)$", text(), re.MULTILINE)}
-    anchors = set()
-    for line in (WIKI / "Glossary.md").read_text(encoding="utf-8").splitlines():
-        anchors.update(re.findall(rf"{NAME}\.md#([a-z0-9-]+)", line))
-    assert anchors, "the guard collected nothing"
-    assert anchors <= heads, sorted(anchors - heads)
-
-
-def test_no_addresses_and_no_em_dashes():
-    body = text()
-    assert set(ADDR.findall(body)) <= {"127.0.0.1"}, set(ADDR.findall(body))
-    assert "—" not in body
-
-
-def test_the_address_guard_bites():
-    assert not set(ADDR.findall("ping 192.0.2.7")) <= {"127.0.0.1"}
-
-
-def test_the_lab_commands_stay_on_the_local_machine():
-    cmds = "\n".join(blocks("bash") + blocks("ini"))
-    assert "ansible_connection=local" in cmds and "ansible-playbook" in cmds, "the guard collected nothing"
-    assert not remote_targets(cmds)
-
-
-def test_the_remote_guard_bites():
-    assert remote_targets("web ansible_host=203.0.113.9")
-    assert remote_targets("ssh admin@box")
-    assert not remote_targets("localhost ansible_connection=local")
-
-
-def test_check_mode_comes_before_the_real_repair_run():
-    ex = text().split("### Exercise 4")[1].split("### Exercise 5")[0]
-    assert ex.index("--check --diff") < ex.rindex("ansible-playbook -i inventory.ini site.yml\n")
-
-
-def test_every_claims_register_row_has_a_status():
-    rows = register_rows(text())
-    assert len(rows) >= 20, "the guard collected too few rows"
-    assert not rows_missing_status(text())
-
-
-def test_the_register_guard_bites():
-    bad = "## Claims register\n\n| Claim | Source | Status |\n|---|---|---|\n| X | y | maybe |\n"
-    assert rows_missing_status(bad) == ["X"]
-
-
-def test_the_estimated_claims_are_marked_in_the_body():
-    body = text()
-    assert body.count("est.") >= 10, "unverified claims must be marked"
-
-
-@pytest.mark.skipif(shutil.which("ansible-playbook") is None, reason="ansible-playbook is not installed")
-def test_the_playbook_is_idempotent_and_the_bad_task_is_not(tmp_path):
-    inventory = next(b for b in blocks("ini") if "[lab]" in b)
-    playbook = next(b for b in blocks("yaml") if "Make a small config directory" in b)
-    bad = next(b for b in re.findall(r"cat > bad\.yml <<'EOF'\n(.*?)\nEOF", "\n".join(blocks("bash")), re.DOTALL))
-    (tmp_path / "inventory.ini").write_text(inventory, encoding="utf-8")
-    (tmp_path / "site.yml").write_text(playbook, encoding="utf-8")
-    (tmp_path / "bad.yml").write_text(bad, encoding="utf-8")
-
-    def run(name: str) -> tuple[int, int]:
-        out = subprocess.run(["ansible-playbook", "-i", "inventory.ini", name], cwd=tmp_path, capture_output=True, text=True, timeout=120, check=False)
-        assert out.returncode == 0, out.stdout + out.stderr
-        m = RECAP.search(out.stdout)
-        assert m, out.stdout
-        return int(m.group(1)), int(m.group(2))
-
-    assert run("site.yml") == (3, 3)
-    assert run("site.yml") == (3, 0)
-    assert run("bad.yml")[1] == 1 and run("bad.yml")[1] == 1
-    assert (tmp_path / "sandbox" / "bad.conf").read_text(encoding="utf-8").count("retries = 3") == 2

+ 0 - 123
tests/test_cron_timers_init_lesson.py

@@ -1,123 +0,0 @@
-# SPDX-License-Identifier: Apache-2.0
-"""The cron, systemd timers and init scripts lesson: registered, honest about what was run, and safe to follow (issue #457).
-
-docs/wiki/Cron-Systemd-Timers-and-Init-Scripts-vs-Systemd.md teaches a crontab line, a timer pair, a translation table
-and a dated account of which distributions install cron. A broken link, a missing registration, a distro claim with no
-source or an **est.** mark, a real address, or a weekly translation that is wrong would each teach the wrong thing.
-"""
-
-import re
-from pathlib import Path
-
-from wikitext import page_text
-
-ROOT = Path(__file__).resolve().parent.parent
-WIKI = ROOT / "docs" / "wiki"
-NAME = "Cron-Systemd-Timers-and-Init-Scripts-vs-Systemd"
-PAGE = WIKI / f"{NAME}.md"
-LINK = re.compile(r"\]\(([A-Za-z0-9_-]+)\.md(?:#[^)]*)?\)")
-ADDR = re.compile(r"\b(?:\d{1,3}\.){3}\d{1,3}\b")
-STATUS_WORDS = ("Read", "Run", "Observed", "**est.**", "Statement of opinion")
-
-
-def text() -> str:
-    return page_text(PAGE)
-
-
-def register_rows(body: str) -> list[list[str]]:
-    reg = body.split("## Claims register")[1]
-    rows = [line for line in reg.splitlines() if line.startswith("|") and not line.startswith("|---")]
-    return [[c.strip() for c in r.strip("|").split("|")] for r in rows[1:]]
-
-
-def rows_missing_status(body: str) -> list[str]:
-    return [r[0] for r in register_rows(body) if not any(w in r[-1] for w in STATUS_WORDS)]
-
-
-def heading_slugs(body: str) -> set[str]:
-    slugs = set()
-    for h in re.findall(r"^#+ (.+)$", body, re.MULTILINE):
-        s = re.sub(r"[^a-z0-9 -]", "", h.lower()).replace(" ", "-")
-        slugs.add(s)
-    return slugs
-
-
-def test_the_page_exists_and_says_what_was_and_was_not_run():
-    body = text()
-    assert body.startswith("# Cron, systemd timers, and init scripts versus systemd")
-    assert "Status: unverified draft" in body
-    assert "I did not start a timer" in body and "did not edit a crontab" in body
-    assert "2026-11-07" in body
-    assert "Not verified, plainly" in body
-
-
-def test_every_linked_wiki_page_exists():
-    links = set(LINK.findall(text()))
-    assert len(links) >= 5, "the guard collected too few links"
-    missing = sorted(t for t in links if not (WIKI / f"{t}.md").exists())
-    assert not missing, missing
-
-
-def test_the_lesson_is_registered_everywhere():
-    nav = (WIKI / "_nav.yaml").read_text(encoding="utf-8")
-    entry = nav.split(f"page: {NAME},")[1].split("\n")[0]
-    assert 'status: "draft"' in entry
-    for special in ("Contents.md", "_Sidebar.md", "Reading-Order.md"):
-        assert f"{NAME}.md" in (WIKI / special).read_text(encoding="utf-8"), special
-    rows = [l for l in (WIKI / "Glossary.md").read_text(encoding="utf-8").splitlines() if f"{NAME}.md" in l]
-    assert len(rows) >= 7, "expected glossary rows for cron, crontab, timer, SysV init, init script, unit file, journald"
-
-
-def test_glossary_rows_point_at_real_headings():
-    heads = heading_slugs(text())
-    anchors = set()
-    for line in (WIKI / "Glossary.md").read_text(encoding="utf-8").splitlines():
-        anchors.update(re.findall(rf"{NAME}\.md#([a-z0-9-]+)", line))
-    assert anchors, "the guard collected nothing"
-    assert anchors <= heads, sorted(anchors - heads)
-
-
-def test_lessons_that_mention_cron_or_systemctl_link_the_lesson():
-    for lesson in ("Terminal-and-Your-First-Script", "Linux-for-Enterprise-Beginners", "First-Hour-on-a-New-System-Updates-and-Baseline"):
-        assert f"{NAME}.md" in page_text(WIKI / f"{lesson}.md"), lesson
-
-
-def test_no_addresses_and_no_em_dashes():
-    body = text()
-    assert "—" not in body
-    assert not ADDR.findall(body), ADDR.findall(body)
-    assert ADDR.findall("ping 192.0.2.7"), "the address guard does not bite"
-
-
-def test_the_translation_table_gets_weekly_and_the_day_rule_right():
-    body = text()
-    assert "`weekly` means Monday at midnight in systemd" in body
-    assert "`@weekly` | `Sun *-*-* 00:00`" in body
-    assert "the 1st and 15th **or** Fridays" in body or "the 1st and 15th **and** on every Friday" in body
-
-
-def test_the_distro_table_is_dated_and_marks_what_it_did_not_read():
-    section = text().split("## Is cron still installed? What I checked")[1].split("## Init scripts versus systemd")[0]
-    assert "2026-11-07" in section
-    for system in ("Debian", "Ubuntu", "Rocky", "Fedora", "Arch", "openSUSE"):
-        assert system in section, system
-    assert section.count("**est.**") >= 4, "unverified edges must be marked"
-
-
-def test_every_claims_register_row_has_a_status():
-    body = text()
-    rows = register_rows(body)
-    assert len(rows) >= 15, "the guard collected too few rows"
-    assert not rows_missing_status(body)
-
-
-def test_the_status_guard_bites():
-    bad = "## Claims register\n\n| Claim | Source | Status |\n|---|---|---|\n| X | Y | trust me |\n"
-    assert rows_missing_status(bad) == ["X"]
-
-
-def test_the_exercises_never_use_a_destructive_crontab_command():
-    body = text()
-    for block in re.findall(r"```bash\n(.*?)```", body, re.DOTALL):
-        assert "crontab -r" not in block, block
-    assert "crontab -r" in body, "the warning about it is gone"

+ 0 - 124
tests/test_dfir_toolkits_lesson.py

@@ -1,124 +0,0 @@
-# SPDX-License-Identifier: Apache-2.0
-"""The DFIR toolkits and live triage lesson: registered, honest about what was run, and dated (issue #478).
-
-docs/wiki/DFIR-Toolkits-and-Live-Triage-SIFT-Velociraptor-KAPE-and-the-Incident-Response-Workflow.md compares six
-toolkits from their owners' pages, teaches live triage against dead-box imaging, and runs a triage exercise on a machine
-the learner owns. A broken link, a missing registration, a license claim with no status, a real address, or a collection
-command that writes outside the learner's own folder would each teach the wrong thing.
-"""
-
-import re
-from pathlib import Path
-
-from wikitext import page_text
-
-ROOT = Path(__file__).resolve().parent.parent
-WIKI = ROOT / "docs" / "wiki"
-NAME = "DFIR-Toolkits-and-Live-Triage-SIFT-Velociraptor-KAPE-and-the-Incident-Response-Workflow"
-PAGE = WIKI / f"{NAME}.md"
-LINK = re.compile(r"\]\(([A-Za-z0-9_-]+)\.md(?:#[^)]*)?\)")
-ADDR = re.compile(r"\b(?:\d{1,3}\.){3}\d{1,3}\b")
-FENCE = re.compile(r"```bash\n(.*?)```", re.DOTALL)
-STATUS_WORDS = ("Read", "Run", "Page read", "**est.**")
-
-
-def text() -> str:
-    return page_text(PAGE)
-
-
-def register_rows(body: str) -> list[list[str]]:
-    reg = body.split("## Claims register")[1]
-    rows = [line for line in reg.splitlines() if line.startswith("|") and not line.startswith("|---")]
-    return [[c.strip() for c in r.strip("|").split("|")] for r in rows[1:]]
-
-
-def rows_missing_status(body: str) -> list[str]:
-    return [r[0] for r in register_rows(body) if not any(w in r[-1] for w in STATUS_WORDS)]
-
-
-def heading_slugs(body: str) -> set[str]:
-    return {re.sub(r"[^a-z0-9 -]", "", h.lower()).replace(" ", "-") for h in re.findall(r"^#+ (.+)$", body, re.MULTILINE)}
-
-
-def test_the_page_exists_and_says_what_was_and_was_not_run():
-    body = text()
-    assert body.startswith("# DFIR toolkits and live triage")
-    assert "Status: unverified draft" in body
-    assert "**Not run:**" in body and "2026-11-07" in body
-    assert "Not verified, plainly" in body
-
-
-def test_every_linked_wiki_page_exists_and_the_four_named_pages_are_linked():
-    links = set(LINK.findall(text()))
-    assert len(links) >= 8, "the guard collected too few links"
-    missing = sorted(t for t in links if not (WIKI / f"{t}.md").exists())
-    assert not missing, missing
-    for page in ("Build-Your-Own-Mini-SOC", "Logs-SIEM-and-Detection-Basics", "Backups-Recovery-and-Patching", "Careers-Roles-and-What-to-Learn-Next"):
-        assert page in links, page
-
-
-def test_the_lesson_is_registered_everywhere():
-    nav = (WIKI / "_nav.yaml").read_text(encoding="utf-8")
-    entry = nav.split(f"page: {NAME},")[1].split("\n")[0]
-    assert 'status: "draft"' in entry and 'subgroup: "Digital forensics"' in entry
-    for special in ("Contents.md", "_Sidebar.md", "Reading-Order.md"):
-        assert f"{NAME}.md" in (WIKI / special).read_text(encoding="utf-8"), special
-    rows = [l for l in (WIKI / "Glossary.md").read_text(encoding="utf-8").splitlines() if f"{NAME}.md" in l]
-    assert len(rows) >= 5, "expected glossary rows for the new terms"
-
-
-def test_glossary_rows_point_at_real_headings():
-    heads = heading_slugs(text())
-    anchors = set()
-    for line in (WIKI / "Glossary.md").read_text(encoding="utf-8").splitlines():
-        anchors.update(re.findall(rf"{NAME}\.md#([a-z0-9-]+)", line))
-    assert anchors, "the guard collected nothing"
-    assert anchors <= heads, sorted(anchors - heads)
-
-
-def test_no_addresses_and_no_em_dashes():
-    body = text()
-    assert "—" not in body
-    assert not ADDR.findall(body), ADDR.findall(body)
-    assert ADDR.findall("ping 192.0.2.7"), "the address guard does not bite"
-
-
-def test_every_claims_register_row_has_a_status():
-    body = text()
-    assert len(register_rows(body)) >= 20, "the guard collected too few rows"
-    assert not rows_missing_status(body)
-
-
-def test_the_status_guard_bites():
-    bad = "## Claims register\n\n| Claim | Source | Status |\n|---|---|---|\n| X | Y | trust me |\n"
-    assert rows_missing_status(bad) == ["X"]
-
-
-def test_the_toolkit_table_names_every_tool_and_the_closed_ones_are_marked():
-    body = text()
-    section = body.split("## The toolkits at a glance")[1].split("## Live triage and dead-box imaging")[0]
-    for tool in ("SIFT Workstation", "CAINE", "Velociraptor", "KAPE", "FTK Imager", "plaso"):
-        assert tool in section, tool
-    assert section.count("**not open source**") >= 2
-    assert "AGPL-3.0" in section and "Apache-2.0" in section and "2026-11-07" in section
-
-
-def test_the_nist_account_names_both_revisions():
-    section = text().split("## An incident response workflow, and where forensics fits")[1].split("## Mobile and cloud forensics")[0]
-    for needle in ("Revision 2", "Revision 3", "April 2025", "Govern", "lessons learned"):
-        assert needle.lower() in section.lower(), needle
-
-
-def test_certifications_carry_no_prices_and_no_affiliate_links():
-    section = text().split("## Training and certifications")[1].split("## Free exercise")[0]
-    assert not re.search(r"[$€£]\s?\d|\bUSD\b", section)
-    assert "http" not in section and "ref=" not in section
-    assert "GCFE" in section and "GCFA" in section
-
-
-def test_the_exercise_collects_only_into_the_learners_own_folder_and_never_removes_a_crontab():
-    cmds = "\n".join(FENCE.findall(text()))
-    assert "collect.sh" in cmds and "sha256sum -c" in cmds, "the guard collected nothing"
-    assert "crontab -r" not in cmds and "sudo rm" not in cmds
-    assert "mkdir -p ~/triage-lab" in cmds
-    assert not re.search(r">\s*/(etc|usr|var|bin)/", cmds)

+ 0 - 150
tests/test_disk_encryption_veracrypt_lesson.py

@@ -1,150 +0,0 @@
-# SPDX-License-Identifier: Apache-2.0
-"""The disk and file encryption lesson: it is registered, honest about what was run, dated and safe to follow.
-
-docs/wiki/Disk-and-File-Encryption-VeraCrypt-TrueCrypt-History-BitLocker-FileVault-and-LUKS.md teaches encryption at
-rest, the three built-in disk encryptions, VeraCrypt, and the dated TrueCrypt history. A broken link, a missing
-registration, a real-looking password in a command, an undated history claim or an unfinished placeholder would each
-teach the wrong thing.
-"""
-
-import re
-import textwrap
-from pathlib import Path
-
-ROOT = Path(__file__).resolve().parent.parent
-WIKI = ROOT / "docs" / "wiki"
-NAME = "Disk-and-File-Encryption-VeraCrypt-TrueCrypt-History-BitLocker-FileVault-and-LUKS"
-PAGE = WIKI / f"{NAME}.md"
-FENCE = re.compile(r"^[ ]*```(\w*)\n(.*?)^[ ]*```$", re.MULTILINE | re.DOTALL)
-LINK = re.compile(r"\]\(([A-Za-z0-9_-]+)\.md(?:#[^)]*)?\)")
-ADDR = re.compile(r"\b(?:\d{1,3}\.){3}\d{1,3}\b")
-STATUS_WORDS = ("Read", "Observed", "**est.**")
-# a literal password handed to the tool: -p 'x', --new-password='x', or PW='x'
-LITERAL = re.compile(r"""(?:\s-p\s+|--new-password=|\bPW=)'([^']*)'""")
-
-
-def text() -> str:
-    return PAGE.read_text(encoding="utf-8")
-
-
-def blocks(tag: str) -> list[str]:
-    return [textwrap.dedent(b) for t, b in FENCE.findall(text()) if t == tag]
-
-
-def register_rows(body: str) -> list[list[str]]:
-    reg = body.split("## Claims register")[1].split("## Not verified, plainly")[0]
-    rows = [line for line in reg.splitlines() if line.startswith("|") and not line.startswith("|---")]
-    return [[c.strip() for c in r.strip("|").split("|")] for r in rows[1:]]
-
-
-def rows_missing_status(body: str) -> list[str]:
-    return [r[0] for r in register_rows(body) if not any(w in r[-1] for w in STATUS_WORDS)]
-
-
-def non_placeholder_passwords(commands: str) -> list[str]:
-    return [p for p in LITERAL.findall(commands) if "PLACEHOLDER" not in p]
-
-
-def test_the_page_exists_and_says_what_was_and_was_not_run():
-    body = text()
-    assert body.startswith("# Disk and file encryption")
-    assert "Status: unverified draft" in body
-    assert "**Not run:**" in body and "2026-11-07" in body
-    for named in ("a hidden volume", "a keyfile", "BitLocker", "FileVault"):
-        assert named in body.split("**Not run:**")[1].split("Vendor and project statements")[0], named
-    assert "Not verified, plainly" in body
-
-
-def test_no_unfinished_placeholder_is_left_in_the_page():
-    body = text()
-    assert "RESULTS_" not in body and "TODO" not in body and "@@" not in body
-
-
-def test_every_linked_wiki_page_exists():
-    links = set(LINK.findall(text()))
-    assert len(links) >= 8, "the guard collected too few links"
-    missing = sorted(t for t in links if not (WIKI / f"{t}.md").exists())
-    assert not missing, missing
-
-
-def test_the_lesson_is_registered_everywhere():
-    nav = (WIKI / "_nav.yaml").read_text(encoding="utf-8")
-    entry = nav.split(f"page: {NAME},")[1].split("\n")[0]
-    assert 'status: "draft"' in entry
-    for special in ("Contents.md", "_Sidebar.md", "Reading-Order.md"):
-        assert f"{NAME}.md" in (WIKI / special).read_text(encoding="utf-8"), special
-    rows = [l for l in (WIKI / "Glossary.md").read_text(encoding="utf-8").splitlines() if f"{NAME}.md" in l]
-    assert len(rows) >= 10, "expected glossary rows for the new terms"
-
-
-def test_glossary_rows_point_at_real_headings():
-    heads = {re.sub(r"[^a-z0-9 -]", "", h.lower()).strip().replace(" ", "-") for h in re.findall(r"^#+ (.+)$", text(), re.MULTILINE)}
-    anchors = set()
-    for line in (WIKI / "Glossary.md").read_text(encoding="utf-8").splitlines():
-        anchors.update(re.findall(rf"{NAME}\.md#([a-z0-9-]+)", line))
-    assert anchors, "the guard collected nothing"
-    assert anchors <= heads, sorted(anchors - heads)
-
-
-def test_no_addresses_no_em_dashes():
-    body = text()
-    assert "—" not in body
-    assert not ADDR.findall(body), ADDR.findall(body)
-
-
-def test_the_address_guard_bites():
-    assert ADDR.findall("ping 192.0.2.7")
-
-
-def test_every_password_in_a_command_is_a_labeled_placeholder():
-    cmds = "\n".join(blocks("bash"))
-    literals = LITERAL.findall(cmds)
-    assert len(literals) >= 4, "the guard collected too few passwords"
-    assert not non_placeholder_passwords(cmds), non_placeholder_passwords(cmds)
-    assert "Never type a password you use anywhere real" in text()
-
-
-def test_the_password_guard_bites():
-    assert non_placeholder_passwords("veracrypt -C x -p 'hunter2'") == ["hunter2"]
-    assert non_placeholder_passwords("veracrypt -C x -p 'Wrong-PLACEHOLDER-2'") == []
-
-
-def test_every_claims_register_row_has_a_status():
-    rows = register_rows(text())
-    assert len(rows) >= 20, "the guard collected too few rows"
-    assert not rows_missing_status(text())
-
-
-def test_the_register_guard_bites():
-    bad = "## Claims register\n\n| Claim | Source | Status |\n|---|---|---|\n| X | y | maybe |\n\n## Not verified, plainly\n"
-    assert rows_missing_status(bad) == ["X"]
-
-
-def test_the_truecrypt_history_is_dated_and_quotes_the_notice():
-    body = text()
-    section = body.split("## From TrueCrypt to VeraCrypt: a dated history")[1].split("## Where it fits")[0]
-    for date in ("2014-04-14", "2014-05-28", "2014-09-04", "2014-12-30", "2015-04-02", "2015-08-05", "2016-10-17", "2023-10-01", "2026-06-09"):
-        assert date in section, date
-    assert "WARNING: Using TrueCrypt is not secure as it may contain unfixed security issues" in section
-    assert "two High, none Medium, one Low, one Undetermined" in section
-    assert "8 critical, 3 medium and 15 low" in section
-    assert "(secondary)" in section, "Wikipedia-only rows must be marked secondary"
-
-
-def test_hidden_volumes_are_given_with_their_honest_limits():
-    body = text()
-    section = body.split("### Hidden volumes and plausible deniability, with the limits")[1].split("### Use across")[0]
-    for needle in ("several points over time", "wear-leveling", "TRIM", "1.18a", "must recreate both the outer and hidden volumes", "legal"):
-        assert needle in section, needle
-
-
-def test_the_three_platform_tools_and_the_comparison_are_present():
-    section = text().split("## Full-disk encryption by platform")[1].split("## Three layers")[0]
-    for needle in ("BitLocker", "FileVault", "LUKS", "XTS", "recovery key", "TPM"):
-        assert needle in section, needle
-
-
-def test_the_defaults_quoted_match_the_documentation_values():
-    body = text()
-    assert "500,000 iterations" in body and "200,000" in body
-    assert "416 MiB" in body and "6 passes" in body

+ 0 - 118
tests/test_disk_forensics_lesson.py

@@ -1,118 +0,0 @@
-# SPDX-License-Identifier: Apache-2.0
-"""The disk forensics lesson: it is registered, honest about what was run, and safe to follow.
-
-docs/wiki/Disk-Forensics-with-Autopsy-and-The-Sleuth-Kit.md teaches imaging, hashing first and The Sleuth Kit commands
-on a practice image the reader builds. A broken link, a missing registration, a claim with no status, a real address,
-a missing authorization rule or a hash step placed after the examination would each teach the wrong thing.
-"""
-
-import re
-from pathlib import Path
-
-ROOT = Path(__file__).resolve().parent.parent
-WIKI = ROOT / "docs" / "wiki"
-NAME = "Disk-Forensics-with-Autopsy-and-The-Sleuth-Kit"
-PAGE = WIKI / f"{NAME}.md"
-LINK = re.compile(r"\]\(([A-Za-z0-9_-]+)\.md(?:#[^)]*)?\)")
-ADDR = re.compile(r"\b(?:\d{1,3}\.){3}\d{1,3}\b")
-STATUS_WORDS = ("Read", "Observed", "Search summary only", "**est.**")
-
-
-def text() -> str:
-    return PAGE.read_text(encoding="utf-8")
-
-
-def register_rows(body: str) -> list[list[str]]:
-    reg = body.split("## Claims register")[1].split("Not verified, plainly")[0]
-    rows = [line for line in reg.splitlines() if line.startswith("|") and not line.startswith("|---")]
-    return [[c.strip() for c in r.strip("|").split("|")] for r in rows[1:]]
-
-
-def rows_missing_status(body: str) -> list[str]:
-    return [r[0] for r in register_rows(body) if not any(w in r[-1] for w in STATUS_WORDS)]
-
-
-def test_the_page_says_what_was_and_was_not_run():
-    body = text()
-    assert body.startswith("# Disk forensics with Autopsy and The Sleuth Kit")
-    assert "Status: unverified draft" in body
-    assert "Autopsy itself was not installed or started" in body
-    assert "**Not run:**" in body and "2026-11-07" in body
-    assert "Not verified, plainly" in body
-
-
-def test_every_linked_wiki_page_exists_and_the_gap_check_links_are_present():
-    links = set(LINK.findall(text()))
-    missing = sorted(t for t in links if not (WIKI / f"{t}.md").exists())
-    assert not missing, missing
-    for needed in (
-        "Hashing-Encryption-and-Keys",
-        "Virtual-Machines-Hypervisors-Desktop-and-Datacenter-Options",
-        "Terminal-and-Your-First-Script",
-    ):
-        assert needed in links, needed
-
-
-def test_sibling_forensics_lessons_are_linked_and_the_pages_exist():
-    # Was: siblings are plain text. The siblings are on main now, so each is a link to a page that exists.
-    hand_written = re.sub(r"<!-- BEGIN GENERATED .*?<!-- END GENERATED [^>]*-->", "", text(), flags=re.DOTALL)
-    links = set(LINK.findall(hand_written))
-    for prefix in ("Digital-Forensics-Foundations", "Memory-Forensics", "Network-Log-and-Timeline-Forensics", "DFIR-Toolkits"):
-        hits = [t for t in links if t.startswith(prefix)]
-        assert hits, prefix
-        assert all((WIKI / f"{t}.md").exists() for t in hits), prefix
-    assert "They are not linked here" not in hand_written
-
-
-def test_the_lesson_is_registered_everywhere():
-    nav = (WIKI / "_nav.yaml").read_text(encoding="utf-8")
-    line = nav.split(f"page: {NAME},")[1].split("\n")[0]
-    assert 'status: "draft"' in line and 'subgroup: "Digital forensics"' in line
-    for special in ("Contents.md", "_Sidebar.md", "Reading-Order.md"):
-        assert f"{NAME}.md" in (WIKI / special).read_text(encoding="utf-8"), special
-    rows = [l for l in (WIKI / "Glossary.md").read_text(encoding="utf-8").splitlines() if f"{NAME}.md" in l]
-    assert len(rows) >= 4
-
-
-def test_glossary_rows_point_at_real_headings():
-    heads = {re.sub(r"[^a-z0-9-]", "", re.sub(r"[^a-z0-9 -]", "", h.lower()).strip().replace(" ", "-")) for h in re.findall(r"^#+ (.+)$", text(), re.MULTILINE)}
-    anchors = set()
-    for line in (WIKI / "Glossary.md").read_text(encoding="utf-8").splitlines():
-        anchors.update(re.findall(rf"{NAME}\.md#([a-z0-9-]+)", line))
-    assert anchors, "the guard collected nothing"
-    assert anchors <= heads, sorted(anchors - heads)
-
-
-def test_no_addresses_no_em_dashes_no_callsign_style_placeholders_missing():
-    body = text()
-    assert not ADDR.findall(body)
-    assert "—" not in body
-
-
-def test_the_authorization_rule_is_stated_up_front():
-    body = text()
-    assert body.index("Examine only your own devices or data you are explicitly authorized to examine") < body.index("## What you will be able to do")
-    assert "not legal advice" in body
-
-
-def test_the_hash_step_comes_before_the_examination_commands():
-    body = text()
-    assert body.index("sha256sum lab.dd > lab.dd.sha256") < body.index("mmls lab.dd\n   fsstat")
-    assert re.search(r"`[0-9a-f]{64}`|[0-9a-f]{64}  lab\.dd", body)
-
-
-def test_every_claims_register_row_has_a_status():
-    rows = register_rows(text())
-    assert len(rows) >= 25, "the guard collected too few rows"
-    assert not rows_missing_status(text())
-
-
-def test_the_register_guard_bites():
-    bad = "## Claims register\n\n| Claim | Source | Status |\n|---|---|---|\n| X | y | maybe |\n\nNot verified, plainly"
-    assert rows_missing_status(bad) == ["X"]
-
-
-def test_versions_and_licenses_are_dated():
-    body = text()
-    for needle in ("4.23.1", "4.15.0", "2026-05-07", "2026-04-15", "Apache License", "Common Public License", "October 2023"):
-        assert needle in body, needle

+ 0 - 129
tests/test_hsm_lesson.py

@@ -1,129 +0,0 @@
-# SPDX-License-Identifier: Apache-2.0
-"""The hardware security modules lesson: it is registered, honest about what was run, and safe to follow.
-
-docs/wiki/Hardware-Security-Modules-What-They-Are-and-Building-Your-Own-with-pico2hsm.md teaches what an HSM is and
-walks a learner through an untested pico2hsm exercise. A missing registration, a broken link, a published sample PIN,
-a claim with no status, or the untested marking going missing would each teach the wrong thing.
-"""
-
-import re
-import shutil
-import subprocess
-import textwrap
-from pathlib import Path
-
-import pytest
-
-ROOT = Path(__file__).resolve().parent.parent
-WIKI = ROOT / "docs" / "wiki"
-NAME = "Hardware-Security-Modules-What-They-Are-and-Building-Your-Own-with-pico2hsm"
-PAGE = WIKI / f"{NAME}.md"
-FENCE = re.compile(r"^[ ]*```(\w*)\n(.*?)^[ ]*```$", re.MULTILINE | re.DOTALL)
-LINK = re.compile(r"\]\(([A-Za-z0-9_-]+)\.md(?:#[^)]*)?\)")
-STATUS_WORDS = ("Read", "Observed", "General knowledge", "**est.**")
-SAMPLE_PINS = ("648219", "3537363231383830", "57621880")  # the values the project's own docs publish
-
-
-def text() -> str:
-    return PAGE.read_text(encoding="utf-8")
-
-
-def register_rows(body: str) -> list[list[str]]:
-    reg = body.split("## Claims register")[1]
-    rows = [line for line in reg.splitlines() if line.startswith("|") and not line.startswith("|---")]
-    return [[c.strip() for c in r.strip("|").split("|")] for r in rows[1:]]
-
-
-def rows_missing_status(body: str) -> list[str]:
-    return [r[0] for r in register_rows(body) if not any(w in r[-1] for w in STATUS_WORDS)]
-
-
-def test_the_page_says_what_was_and_was_not_run():
-    body = text()
-    assert body.startswith("# Hardware security modules")
-    assert "Status: unverified draft" in body
-    assert "**Not run:**" in body and "2026-11-07" in body
-    assert "no Pico 2 was available" in body
-
-
-def test_part_b_is_marked_untested_and_the_maintainer_checks_exist():
-    body = text()
-    assert "Part B: the same on a Pico 2 (UNTESTED)" in body
-    assert "**Untested.**" in body
-    checks = body.split("## For the maintainer: checks to run when you build it")[1].split("## Checkpoint")[0]
-    assert len(re.findall(r"^\d+\. ", checks, re.MULTILINE)) >= 10
-
-
-def test_every_linked_wiki_page_exists():
-    links = set(LINK.findall(text()))
-    assert len(links) >= 6, "the guard collected too few links"
-    missing = sorted(t for t in links if not (WIKI / f"{t}.md").exists())
-    assert not missing, missing
-
-
-def test_the_lesson_is_registered_everywhere():
-    nav = (WIKI / "_nav.yaml").read_text(encoding="utf-8")
-    assert f"page: {NAME}," in nav and 'status: "draft"' in nav.split(f"page: {NAME},")[1].split("\n")[0]
-    for special in ("Contents.md", "_Sidebar.md", "Reading-Order.md"):
-        assert f"{NAME}.md" in (WIKI / special).read_text(encoding="utf-8"), special
-    rows = [row for row in (WIKI / "Glossary.md").read_text(encoding="utf-8").splitlines() if f"{NAME}.md" in row]
-    assert len(rows) >= 5, "expected glossary rows for the new terms"
-
-
-def test_glossary_rows_point_at_real_headings():
-    def slug(h: str) -> str:
-        return re.sub(r"[^a-z0-9-]", "", h.lower().replace(" ", "-"))
-
-    heads = {slug(h) for h in re.findall(r"^#+ (.+)$", text(), re.MULTILINE)}
-    anchors = set()
-    for line in (WIKI / "Glossary.md").read_text(encoding="utf-8").splitlines():
-        anchors.update(re.findall(rf"{NAME}\.md#([a-z0-9-]+)", line))
-    assert anchors, "the guard collected nothing"
-    assert anchors <= heads, sorted(anchors - heads)
-
-
-def test_no_em_dashes_and_no_published_sample_pins():
-    body = text()
-    assert "—" not in body
-    found = [p for p in SAMPLE_PINS if p in body]
-    assert not found, found
-
-
-def test_the_pin_guard_bites():
-    assert [p for p in SAMPLE_PINS if p in "sc-hsm-tool --pin 648219"] == ["648219"]
-
-
-def test_every_claims_register_row_has_a_status():
-    rows = register_rows(text())
-    assert len(rows) >= 20, "the guard collected too few rows"
-    assert not rows_missing_status(text())
-
-
-def test_the_register_guard_bites():
-    bad = "## Claims register\n\n| Claim | Source | Status |\n|---|---|---|\n| X | y | maybe |\n"
-    assert rows_missing_status(bad) == ["X"]
-
-
-def test_the_page_quotes_the_projects_own_limits():
-    body = text()
-    assert "not a certified secure element" in body
-    assert "Never deploy either: the development storage key is public." in body
-    assert "A4" in body and "RP2350-E24" in body
-
-
-@pytest.mark.skipif(shutil.which("openssl") is None, reason="openssl is not installed")
-def test_part_a_signs_verifies_and_fails_on_a_changed_message(tmp_path):
-    block = next(textwrap.dedent(b) for t, b in FENCE.findall(text()) if t == "bash" and "ecparam" in b)
-    steps = block.replace("mkdir -p ~/hsmlab && cd ~/hsmlab", f"cd {tmp_path}")
-    steps = steps.split("# 4.")[0]  # up to and including the first verify
-    ok = subprocess.run(["bash", "-eu", "-c", steps], capture_output=True, text=True, timeout=60, check=False)
-    assert ok.returncode == 0, ok.stderr
-    assert "Verified OK" in ok.stdout + ok.stderr
-    bad = subprocess.run(
-        ["bash", "-c", f"cd {tmp_path} && echo tamper >> msg.txt && openssl dgst -sha256 -verify pub.der -keyform DER -signature sig.bin msg.txt"],
-        capture_output=True,
-        text=True,
-        timeout=60,
-        check=False,
-    )
-    assert bad.returncode != 0

+ 603 - 0
tests/test_lesson_guards.py

@@ -0,0 +1,603 @@
+# SPDX-License-Identifier: Apache-2.0
+"""One data-driven guard suite for every lesson page (issue #525).
+
+It replaces the copy-pasted per-lesson guard files. Two layers:
+
+1. GENERIC checks, run on every lesson page the discovery rule finds (see `lesson_pages`): no em dash, no address
+   outside the page's allowlist, no identifier or private key (scripts/identifier_check.py), a status banner that
+   says what was and was not run, a claims register whose rows all carry a known status, link targets and in-page
+   anchors that exist, glossary anchors that resolve, registration in the navigation files, sibling lessons linked
+   rather than named in plain text, and the UNTESTED or **est.** marks where the page says something was not run.
+2. PER-LESSON rows in tests/lesson_guard_data.py (`PAGES`): the thresholds and the unique requirements the old
+   per-lesson files held, as data. A row is a dict; `check_row` below is the only code that reads them.
+
+Every failure names the page and the rule. Each guard has a negative case (`test_guard_bites_*`) proving it fires.
+American English is guarded by tests/test_american_english.py and is not repeated here.
+"""
+
+from __future__ import annotations
+
+import functools
+import importlib.util
+import re
+import shutil
+import subprocess
+import sys
+import textwrap
+from pathlib import Path
+
+import pytest
+from lesson_guard_data import DEFAULTS, NO_REGISTER, PAGES
+from wikitext import gen_wiki_nav, page_text
+
+ROOT = Path(__file__).resolve().parent.parent
+WIKI = ROOT / "docs" / "wiki"
+
+_spec = importlib.util.spec_from_file_location("identifier_check", ROOT / "scripts" / "identifier_check.py")
+ic = importlib.util.module_from_spec(_spec)
+sys.modules.setdefault("identifier_check", ic)
+_spec.loader.exec_module(ic)
+
+FENCE = re.compile(r"^[ ]*```(\w*)\n(.*?)^[ ]*```$", re.MULTILINE | re.DOTALL)
+LINK = re.compile(r"\]\(([A-Za-z0-9_-]+)\.md(?:#[^)]*)?\)")
+OWN_ANCHOR = re.compile(r"\]\(#([^)\s]+)\)")
+ADDR = re.compile(r"\b(?:\d{1,3}\.){3}\d{1,3}\b")
+PRIVATE_KEY = re.compile(r"-----BEGIN [A-Z ]*PRIVATE KEY-----")
+BANNER = re.compile(r"^> \*\*Status:.*?(?=\n\n)", re.MULTILINE | re.DOTALL)
+HONEST = re.compile(
+    r"not run|nothing run|nothing was run|no command|was run|were run|run once|did not|not built|not applied|has not been|have not been|not seen to work|not verified|no \w+ was|not installed|not tested|written from reading",
+    re.IGNORECASE,
+)
+NOT_RUN = re.compile(r"\*\*Not run:\*\*|nothing run|not run|did not run|no command on this page was run|has not been run|have not been run|not built", re.IGNORECASE)
+MARKS = ("**est.**", "UNTESTED", "**Untested", "**not verified**", "Not verified, plainly")
+# "unverified draft" is the banner label every draft page carries, not a statement that something was not run
+UNRUN_SAYS = re.compile(
+    r"did not run|was not run|were not run|not run\b|never run|I did not|could not run|untested|not tested|not verified|unverified(?! draft)",
+    re.IGNORECASE,
+)
+DATE = re.compile(r"\d{4}-\d{2}-\d{2}")
+SIBLING_WORDING = ("plain text until", "They are not linked here")
+NAV_PLACES = ("Contents.md", "_Sidebar.md", "Reading-Order.md")
+
+
+# -- discovery ---------------------------------------------------------------------------------------------
+
+
+@functools.cache
+def read(path: Path) -> str:
+    return path.read_text(encoding="utf-8")
+
+
+@functools.cache
+def nav_entries() -> dict[str, str]:
+    """page name -> its _nav.yaml line, for every entry that carries a `status`."""
+    found = {}
+    for line in read(WIKI / "_nav.yaml").splitlines():
+        m = re.search(r"\bpage: ([^,]+),", line)
+        if m and re.search(r'\bstatus: "', line):
+            found[m.group(1)] = line
+    return found
+
+
+def lesson_pages() -> list[str]:
+    """The discovery rule: a page is a lesson when its _nav.yaml entry carries a `status` AND the page has a
+    `## Claims register` section. Those two together are what every old per-lesson file guarded; the status-only
+    pages without a register (the cloud-provider and telemetry pages) are not lessons of this form."""
+    names = []
+    for name in nav_entries():
+        page = WIKI / f"{name}.md"
+        if page.exists() and "## Claims register" in read(page):
+            names.append(name)
+    return sorted(names)
+
+
+LESSONS = lesson_pages()
+
+
+def cfg(name: str) -> dict:
+    return {**DEFAULTS, **PAGES.get(name, {}).get("config", {})}
+
+
+@functools.cache
+def text(name: str) -> str:
+    return page_text(WIKI / f"{name}.md")
+
+
+# -- helpers (each one has a negative case below) ------------------------------------------------------------
+
+
+def register_rows(body: str) -> list[list[str]]:
+    reg = body.split("## Claims register")[1]
+    nxt = re.search(r"^## ", reg, re.MULTILINE)
+    reg = reg[: nxt.start()] if nxt else reg
+    rows = [line for line in reg.splitlines() if line.startswith("|") and not re.match(r"^\|[\s:|-]+\|?$", line)]
+    return [[c.strip() for c in r.strip().strip("|").split("|")] for r in rows[1:]]
+
+
+def rows_with_bad_status(body: str, words: tuple[str, ...]) -> list[str]:
+    bad = []
+    for r in register_rows(body):
+        status = r[-1] if len(r) >= 3 else ""
+        if not status or not any(w in status for w in words):
+            bad.append(r[0][:60])
+    return bad
+
+
+def addresses_outside(body: str, allow: tuple[str, ...]) -> list[str]:
+    return sorted({a for a in ADDR.findall(body) if not any(re.fullmatch(p, a) for p in allow)})
+
+
+def dead_links(body: str) -> list[str]:
+    return sorted({t for t in LINK.findall(body) if not (WIKI / f"{t}.md").exists()})
+
+
+def dead_own_anchors(body: str) -> list[str]:
+    heads = {a for _, _, a in gen_wiki_nav.page_headings(body)}
+    return sorted({a for a in OWN_ANCHOR.findall(body) if a not in heads})
+
+
+def glossary_anchors(name: str) -> set[str]:
+    found: set[str] = set()
+    for line in read(WIKI / "Glossary.md").splitlines():
+        found.update(re.findall(rf"{re.escape(name)}\.md#([a-z0-9_-]+)", line))
+    return found
+
+
+def glossary_rows(name: str) -> int:
+    return sum(1 for line in read(WIKI / "Glossary.md").splitlines() if f"{name}.md" in line)
+
+
+# The repository gate `identifier_check.py --root .` scans every tracked file with every pattern. This suite applies
+# the gate's own scan_line (all pattern kinds: AWS, Azure, GCP; its placeholder allowlist; its ignore marker) to each
+# lesson page, so a page cannot publish a real-looking account, tenant, project or key id, and adds private keys.
+def identifier_findings(body: str) -> list[str]:
+    kinds = [kind for line in body.splitlines() for kind in ic.scan_line(line)]
+    if PRIVATE_KEY.search(body):
+        kinds.append("private key block")
+    return kinds
+
+
+def identifier_problem(name: str, body: str) -> str | None:
+    kinds = identifier_findings(body)
+    return fail(name, "no cloud account, tenant, project or key id and no private key (patterns of scripts/identifier_check.py)", kinds) if kinds else None
+
+
+def banner_problem(name: str, body: str, nav_status: str) -> str | None:
+    banner = banner_of(body)
+    if not banner:
+        return fail(name, "status banner", "no '> **Status:' blockquote")
+    if not DATE.search(banner):  # the banner itself, never the introduction
+        return fail(name, "status banner is dated", "no date inside the banner text")
+    if not HONEST.search(banner):
+        return fail(name, "status banner says what was or was not run", banner[:120])
+    if nav_status == "draft" and "unverified draft" not in banner:
+        return fail(name, "draft banner", "nav says draft but the banner does not say 'unverified draft'")
+    return None
+
+
+def unrun_problem(name: str, body: str, extra_marks: tuple[str, ...] = ()) -> str | None:
+    """Anywhere in the page, a statement that something was not run needs an unrun mark somewhere on the page."""
+    hit = UNRUN_SAYS.search(body)
+    if hit and not any(m in body for m in MARKS + tuple(extra_marks)):
+        return fail(name, "an UNTESTED / **est.** / not-verified mark", f"the page says {hit.group(0)!r} but carries no mark")
+    return None
+
+
+def banner_of(body: str) -> str:
+    m = BANNER.search(body)
+    return m.group(0) if m else ""
+
+
+def strip_generated_comment_blocks(body: str) -> str:
+    return re.sub(r"<!-- BEGIN GENERATED .*?<!-- END GENERATED [^>]*-->", "", body, flags=re.DOTALL)
+
+
+def blocks(body: str, tag: str) -> list[str]:
+    return [textwrap.dedent(b) for t, b in FENCE.findall(body) if t == tag]
+
+
+def fail(name: str, rule: str, detail: object) -> str:
+    return f"[{name}] rule '{rule}' failed: {detail}"
+
+
+# -- the generic checks ----------------------------------------------------------------------------------------
+
+
+def test_discovery_finds_every_page_the_old_files_guarded():
+    # the pages the deleted per-lesson files named; a lesson that stops being discovered must fail loudly
+    assert len(LESSONS) >= 50, f"discovery collected only {len(LESSONS)} lesson pages"
+    missing = sorted(set(PAGES) - set(LESSONS))
+    assert not missing, f"pages with guard rows that discovery no longer finds (status or claims register gone?): {missing}"
+
+
+def test_every_status_page_is_a_lesson_or_listed_as_having_no_register():
+    for name in nav_entries():
+        if name in LESSONS:
+            assert name not in NO_REGISTER, f"[{name}] rule 'discovery': now has a claims register; remove it from NO_REGISTER in tests/lesson_guard_data.py"
+        else:
+            assert name in NO_REGISTER, (
+                f"[{name}] rule 'discovery': carries a status in _nav.yaml but has no '## Claims register'. "
+                "A lesson that lost its register must get it back; a new page without one goes in NO_REGISTER in tests/lesson_guard_data.py"
+            )
+    assert not [n for n in NO_REGISTER if n not in nav_entries()], "NO_REGISTER names a page that no longer carries a status"
+
+
+@pytest.mark.parametrize("name", LESSONS)
+def test_page_title_and_no_em_dash(name):
+    body = text(name)
+    assert body.startswith("# "), fail(name, "title", "the page does not start with a level-1 heading")
+    assert "—" not in body, fail(name, "no em dash", f"em dash at line {body[: body.index('—')].count(chr(10)) + 1}")
+
+
+@pytest.mark.parametrize("name", LESSONS)
+def test_page_addresses_are_documented_placeholders_only(name):
+    body = text(name)
+    c = cfg(name)
+    exact = "addresses_allow" in PAGES.get(name, {}).get("config", {})  # an exact list replaces the shared defaults
+    allow = tuple(c["addresses_allow"]) if exact else tuple(c["addresses_default"]) + tuple(c.get("addresses_extra", ()))
+    found = addresses_outside(body, allow)
+    assert not found, fail(name, "no addresses beyond the page's allowlist", found)
+    for needed in c.get("addresses_require", ()):
+        assert needed in ADDR.findall(body), fail(name, "address guard collected nothing", needed)
+
+
+@pytest.mark.parametrize("name", LESSONS)
+def test_page_has_no_identifier_or_private_key(name):
+    problem = identifier_problem(name, text(name))
+    assert problem is None, problem
+
+
+@pytest.mark.parametrize("name", LESSONS)
+def test_page_status_banner_says_what_was_and_was_not_run(name):
+    body = text(name)
+    nav_status = re.search(r'\bstatus: "([^"]*)"', nav_entries()[name]).group(1)
+    problem = banner_problem(name, body, nav_status)
+    assert problem is None, problem
+    assert NOT_RUN.search(body[:6000]) or "run" in banner_of(body).lower(), fail(name, "says what was not run", "no 'Not run' statement near the top")
+
+
+@pytest.mark.parametrize("name", LESSONS)
+def test_page_marks_what_was_not_run(name):
+    problem = unrun_problem(name, text(name), cfg(name).get("unrun_marks_extra", ()))
+    assert problem is None, problem
+
+
+@pytest.mark.parametrize("name", LESSONS)
+def test_page_claims_register_rows_all_have_a_known_status(name):
+    body = text(name)
+    c = cfg(name)
+    rows = register_rows(body)
+    assert len(rows) >= c["min_register_rows"], fail(name, "claims register size", f"{len(rows)} rows, expected at least {c['min_register_rows']}")
+    exact = "status_words" in PAGES.get(name, {}).get("config", {})  # an exact list replaces the shared vocabulary
+    words = tuple(c["status_words"]) if exact else tuple(c["status_words"]) + tuple(c.get("status_extra", ()))
+    bad = rows_with_bad_status(body, words)
+    assert not bad, fail(name, f"claims register status in {words}", bad)
+
+
+@pytest.mark.parametrize("name", LESSONS)
+def test_page_links_and_anchors_resolve(name):
+    body = text(name)
+    c = cfg(name)
+    links = set(LINK.findall(body))
+    assert len(links) >= c["min_links"], fail(name, "link guard collected too few links", f"{len(links)} < {c['min_links']}")
+    assert not dead_links(body), fail(name, "every linked wiki page exists", dead_links(body))
+    assert not dead_own_anchors(body), fail(name, "every in-page anchor points at a heading", dead_own_anchors(body))
+    for needed in c.get("must_link", ()):
+        assert needed in links, fail(name, "required link present", needed)
+    for prefix in c.get("must_link_prefix", ()):
+        hits = [t for t in set(LINK.findall(strip_generated_comment_blocks(body))) if t.startswith(prefix)]
+        assert hits, fail(name, "sibling lesson is linked, not named in plain text", prefix)
+        assert all((WIKI / f"{t}.md").exists() for t in hits), fail(name, "sibling link target exists", prefix)
+
+
+@pytest.mark.parametrize("name", LESSONS)
+def test_page_does_not_say_siblings_are_plain_text(name):
+    body = strip_generated_comment_blocks(text(name))
+    found = [w for w in SIBLING_WORDING if w in body]
+    assert not found, fail(name, "no 'plain text until' sibling wording", found)
+
+
+@pytest.mark.parametrize("name", LESSONS)
+def test_page_is_registered_and_glossary_anchors_resolve(name):
+    c = cfg(name)
+    line = nav_entries()[name]
+    for extra in c.get("nav_contains", ()):
+        assert extra in line, fail(name, "nav entry carries", extra)
+    for special in NAV_PLACES:
+        if special in c.get("nav_places_skip", ()):
+            continue
+        assert f"{name}.md" in read(WIKI / special), fail(name, "registered in navigation file", special)
+    assert glossary_rows(name) >= c["min_glossary_rows"], fail(name, "glossary rows for the new terms", f"{glossary_rows(name)} < {c['min_glossary_rows']}")
+    anchors = glossary_anchors(name)
+    if c["min_glossary_rows"] > 0:
+        assert anchors, fail(name, "glossary guard collected nothing", "no Glossary.md row links an anchor of this page")
+    heads = {a for _, _, a in gen_wiki_nav.page_headings(text(name))}
+    assert anchors <= heads, fail(name, "glossary anchors resolve", sorted(anchors - heads))
+
+
+# -- the generic guards bite (negative cases) -------------------------------------------------------------------
+
+
+REGISTER_BAD = "## Claims register\n\n| Claim | Source | Status |\n|---|---|---|\n| X | y | maybe |\n| Z | y |  |\n"
+
+
+def test_guard_bites_register_status():
+    assert rows_with_bad_status(REGISTER_BAD, ("Read",)) == ["X", "Z"]
+    assert rows_with_bad_status("## Claims register\n\n| Claim | Source | Status |\n|---|---|---|\n| X | y | Read |\n", ("Read",)) == []
+
+
+def test_guard_bites_addresses():
+    assert addresses_outside("ping 192.0.2.7", ()) == ["192.0.2.7"]
+    assert addresses_outside("ping 127.0.0.1", (r"127\.0\.0\.1",)) == []
+    assert addresses_outside("ping 127.0.0.2", (r"127\.0\.0\.1",)) == ["127.0.0.2"]
+
+
+def test_guard_bites_links_and_anchors():
+    assert dead_links("see [x](No-Such-Page-Anywhere.md)") == ["No-Such-Page-Anywhere"]
+    assert dead_links(f"see [x]({LESSONS[0]}.md#a)") == []
+    assert dead_own_anchors("# Title\n\n[x](#no-such-heading)") == ["no-such-heading"]
+    assert dead_own_anchors("# Title\n\n[x](#title)") == []
+
+
+UUID_REAL = "3f2a9c1e-7b44-4d0a-9e51-8c6d2b7a1f03"  # shaped like a real id, made up for this test
+
+
+def test_guard_bites_identifiers():
+    assert identifier_findings("-----BEGIN RSA PRIVATE KEY-----")
+    assert identifier_findings("key " + "AKIA" + "ABCDEFGHIJKLMNOP") == ["AWS access key id"]
+    assert not identifier_findings("nothing secret here")
+    # every kind in the gate's pattern list, not just the first Azure form
+    assert identifier_findings(f"az group list --id /subscriptions/{UUID_REAL}/resourceGroups/x") == ["Azure subscription id in a resource path"]
+    assert identifier_findings(f"https://login.microsoftonline.com/{UUID_REAL}/oauth2/v2.0/token") == ["Azure tenant id in a sign-in URL"]
+    assert identifier_findings("arn:aws:iam::" + "210987654321" + ":role/x") == ["AWS ARN account id"]
+    assert "GCP project id" in identifier_findings("project_id = \"real-looking-proj-4821\"")
+    # the documented placeholder forms stay allowed
+    assert not identifier_findings("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/x")
+    assert not identifier_findings("https://login.microsoftonline.com/11111111-1111-1111-1111-111111111111/oauth2")
+    assert not identifier_findings("arn:aws:iam::123456789012:role/x")
+    name = LESSONS[0]
+    assert "rule" in identifier_problem(name, f"/subscriptions/{UUID_REAL}/x") and name in identifier_problem(name, f"/subscriptions/{UUID_REAL}/x")
+    assert identifier_problem(name, "clean") is None
+
+
+UNDATED = "# T\n\n> **Status: unverified draft. Nothing was run.** No date here.\n\nIntro written on 2026-11-07.\n"
+
+
+def test_guard_bites_banner_date_and_unrun_marker():
+    # the date must be in the banner itself: a date in the introduction does not count
+    problem = banner_problem("P", UNDATED, "draft")
+    assert problem and "P" in problem and "dated" in problem
+    assert banner_problem("P", UNDATED.replace("No date here.", "Read on 2026-11-07."), "draft") is None
+    # an unrun statement anywhere in the page needs a mark
+    middle = "# T\n\n> **Status: unverified draft, 2026-11-07. Nothing was run.**\n\n## Body\n\nI did not run X.\n"
+    problem = unrun_problem("P", middle)
+    assert problem and "P" in problem and "mark" in problem
+    assert unrun_problem("P", middle + "\nThe step is **est.**\n") is None
+
+
+def test_guard_bites_banner():
+    assert banner_of("# T\n\n> **Status: unverified draft. Nothing was run.**\n\ntext") != ""
+    assert banner_of("# T\n\nno banner here") == ""
+    assert not HONEST.search("> **Status: fine.**")
+
+
+# -- per-lesson rows ---------------------------------------------------------------------------------------------
+
+
+def section(body: str, start: str, end: str | None = None) -> str:
+    assert start in body, f"section start {start!r} not found"
+    rest = body.split(start, 1)[1]
+    if end is not None:
+        assert end in rest, f"section end {end!r} not found after {start!r}"
+        rest = rest.split(end, 1)[0]
+    return rest
+
+
+def check_row(name: str, row: dict) -> None:
+    """Evaluate one data row against its page. Every assertion message names the page, the row and the rule."""
+    body = text(name)
+    rid = f"[{name}] row '{row['id']}'"
+    scope = section(body, row["start"], row.get("end")) if "start" in row else body
+    for needle in row.get("contains", ()):
+        assert needle in scope, f"{rid}: missing {needle!r}"
+    for needle in row.get("contains_ci", ()):
+        assert needle.lower() in scope.lower(), f"{rid}: missing (any case) {needle!r}"
+    if "contains_any" in row:
+        assert any(n in scope for n in row["contains_any"]), f"{rid}: none of {row['contains_any']} is present"
+    for needle in row.get("absent", ()):
+        assert needle not in scope, f"{rid}: must not contain {needle!r}"
+    for needle, allowed in row.get("absent_except", ()):  # the needle may appear only inside the allowed phrase
+        assert needle not in scope.replace(allowed, ""), f"{rid}: {needle!r} appears outside {allowed!r}"
+    for needle, n in row.get("count_at_least", {}).items():
+        assert scope.count(needle) >= n, f"{rid}: {needle!r} appears {scope.count(needle)} times, expected at least {n}"
+    for pattern, n in row.get("regex_count_at_least", {}).items():
+        got = len(re.findall(pattern, scope, re.MULTILINE))
+        assert got >= n, f"{rid}: /{pattern}/ matched {got} times, expected at least {n}"
+    for pattern in row.get("regex_absent", ()):
+        assert not re.search(pattern, scope), f"{rid}: /{pattern}/ must not match"
+    for pattern in row.get("regex_present", ()):
+        assert re.search(pattern, scope), f"{rid}: /{pattern}/ must match"
+    for first, second in row.get("order", ()):
+        assert first in scope and second in scope, f"{rid}: order needles missing ({first!r}, {second!r})"
+        assert scope.index(first) < scope.index(second), f"{rid}: {first!r} must come before {second!r}"
+    for first, second in row.get("order_before_last", ()):  # first occurrence of `first` before the LAST `second`
+        assert first in scope and second in scope, f"{rid}: order needles missing ({first!r}, {second!r})"
+        assert scope.index(first) < scope.rindex(second), f"{rid}: {first!r} must come before the last {second!r}"
+    if "startswith" in row:
+        assert body.startswith(row["startswith"]), f"{rid}: page must start with {row['startswith']!r}"
+    for target in row.get("links_in_scope", ()):
+        assert f"]({target}.md)" in scope, f"{rid}: no link to {target}"
+        assert (WIKI / f"{target}.md").exists(), f"{rid}: {target} does not exist"
+    if "register_row" in row:  # the first register row whose first cell has all `select` words must also have the rest
+        want = row["register_row"]
+        picked = [r for r in register_rows(body) if all(w in r[0] for w in want["select"])]
+        assert picked, f"{rid}: no claims register row selected by {want['select']}"
+        assert all(w in picked[0][0] for w in want.get("first_has", ())), f"{rid}: register row {picked[0][0][:60]!r} lacks {want.get('first_has')}"
+        assert all(w in picked[0][1] for w in want.get("second_has", ())), f"{rid}: register row source cell lacks {want.get('second_has')}"
+    if "inbound_min" in row:
+        skip = {"Glossary.md", "_Sidebar.md", "Reading-Order.md", "Contents.md", f"{name}.md"}
+        inbound = [p.name for p in WIKI.glob("*.md") if p.name not in skip and f"{name}.md" in p.read_text(encoding="utf-8")]
+        assert len(inbound) >= row["inbound_min"], f"{rid}: only {len(inbound)} inbound lessons link here: {inbound}"
+    for lesson in row.get("inbound_all", ()):
+        assert f"{name}.md" in page_text(WIKI / f"{lesson}.md"), f"{rid}: {lesson} does not link this lesson"
+    urls = re.findall(r"\]\((https?://[^)]+)\)", body)
+    if "urls_min" in row:
+        assert len(urls) >= row["urls_min"], f"{rid}: the url guard collected {len(urls)} urls"
+    if "url_forbid" in row:
+        bad = urls_matching(urls, row["url_forbid"])
+        assert not bad, f"{rid}: forbidden url form {bad}"
+    if "code" in row:
+        check_code(rid, body, row["code"])
+    if "numbered_items_min" in row:
+        got = len(re.findall(r"^\d+\. ", scope, re.MULTILINE))
+        assert got >= row["numbered_items_min"], f"{rid}: {got} numbered items, expected at least {row['numbered_items_min']}"
+    for vendor, must in row.get("vendor_sections", {}).items():
+        sec = vendor_section(body, vendor)
+        for needle in must:
+            assert needle in sec, f"{rid}: section '### {vendor}' lacks {needle!r}"
+
+
+def vendor_section(body: str, heading: str) -> str:
+    start = body.index(f"### {heading}")
+    first_line_end = body.index("\n", start) + 1
+    rest = body[first_line_end:]
+    nxt = re.search(r"^#{2,3} ", rest, re.MULTILINE)
+    return body[start : first_line_end + (nxt.start() if nxt else len(rest))]
+
+
+def urls_matching(urls: list[str], pattern: str) -> list[str]:
+    return [u for u in urls if re.search(pattern, u, re.IGNORECASE)]
+
+
+def matches_in(commands: str, pattern: str, flags: int = 0) -> list[str]:
+    """Every match of `pattern` in the commands, as the line it starts on (the pattern may span a line break)."""
+    found = []
+    for m in re.finditer(pattern, commands, flags):
+        start = commands.rfind("\n", 0, m.start()) + 1
+        end = commands.find("\n", m.end())
+        found.append(commands[start : end if end != -1 else len(commands)].strip())
+    return found
+
+
+def check_code(rid: str, body: str, code: dict) -> None:
+    """A code-block guard: collect loosely (the blocks must contain `require`), assert strictly (nothing matches
+    `forbid`; `count_at_least` maps a regex to a minimum), and prove the guard fires on every `bite_bad` sample
+    and stays quiet on every `bite_good` sample."""
+    flags = re.IGNORECASE if code.get("ignorecase") else 0
+    tags = tuple(code.get("tags", ()))
+    chunks = [b for t, b in FENCE.findall(body) if not tags or t in tags]
+    cmds = "\n".join(textwrap.dedent(c) for c in chunks)
+    for needle in code.get("require", ()):
+        assert needle in cmds, f"{rid}: the code guard collected nothing ({needle!r} not in the {tags or 'all'} blocks)"
+    for pattern, n in code.get("count_at_least", {}).items():
+        got = len(re.findall(pattern, cmds, flags))
+        assert got >= n, f"{rid}: the code guard collected {got} matches of /{pattern}/, expected at least {n}"
+    bad = matches_in(cmds, code["forbid"], flags)
+    assert not bad, f"{rid}: forbidden command in a code block: {bad}"
+    for sample in code.get("bite_bad", ()):
+        assert matches_in(sample, code["forbid"], flags), f"{rid}: the guard does not bite on {sample!r}"
+    for sample in code.get("bite_good", ()):
+        assert not matches_in(sample, code["forbid"], flags), f"{rid}: the guard fires on the allowed {sample!r}"
+
+
+def _rows():
+    for name, spec in sorted(PAGES.items()):
+        for row in spec.get("rows", ()):
+            yield pytest.param(name, row, id=f"{name[:40]}::{row['id']}")
+
+
+@pytest.mark.parametrize(("name", "row"), list(_rows()))
+def test_lesson_specific_row(name, row):
+    check_row(name, row)
+
+
+def test_every_row_has_an_id_and_something_to_assert():
+    keys = {"contains", "absent", "count_at_least", "regex_count_at_least", "regex_absent", "regex_present", "order", "order_before_last", "contains_ci", "contains_any", "absent_except", "startswith", "links_in_scope", "register_row", "inbound_min", "inbound_all", "urls_min", "url_forbid", "code", "numbered_items_min", "vendor_sections"}
+    ids = set()
+    for name, spec in PAGES.items():
+        for row in spec.get("rows", ()):
+            assert row.get("id"), f"{name}: a row without an id"
+            assert (name, row["id"]) not in ids, f"{name}: duplicate row id {row['id']}"
+            ids.add((name, row["id"]))
+            assert keys & set(row), f"{name}: row {row['id']} asserts nothing"
+
+
+def test_row_engine_bites():
+    page = LESSONS[0]
+    with pytest.raises(AssertionError, match="missing"):
+        check_row(page, {"id": "x", "contains": ["zzz-not-in-any-page-zzz"]})
+    with pytest.raises(AssertionError, match="must not contain"):
+        check_row(page, {"id": "x", "absent": ["# "]})
+    with pytest.raises(AssertionError, match="must come before"):
+        t = text(page)
+        check_row(page, {"id": "x", "order": [(t[-30:].strip().splitlines()[-1][:20], t[:20])]})
+    with pytest.raises(AssertionError, match="does not bite"):
+        check_row(page, {"id": "x", "code": {"forbid": "zzz-never", "bite_bad": ["nothing"]}})
+    assert matches_in("sudo flashrom -w x", r"\bsudo\b|\bflashrom\b")
+    assert not matches_in("cat /sys/x", r"\bsudo\b|\bflashrom\b")
+    assert urls_matching(["https://example.com/p?ref=abc"], r"[?&]ref=")
+    assert not urls_matching(["https://example.com/p"], r"[?&]ref=")
+    sample = "### A\nFirmware ME\n### B\nother\n"
+    assert "Firmware ME" in vendor_section(sample, "A")
+    assert "other" not in vendor_section(sample, "A")
+
+
+# -- tests that run external tools: kept as code, listed in the PR body -------------------------------------------
+
+
+def _first(body: str, tag: str, needle: str) -> str:
+    return next(b for b in blocks(body, tag) if needle in b)
+
+
+@pytest.mark.skipif(shutil.which("qemu-img") is None, reason="qemu-img is not installed")
+def test_vm_exercise_3_runs_and_the_snapshot_round_trips(tmp_path):
+    body = text("Virtual-Machines-Hypervisors-Desktop-and-Datacenter-Options")
+    script = _first(body, "bash", "qemu-img create").replace("cd ~/vmlab", f"cd {tmp_path}")
+    result = subprocess.run(["bash", "-eu", "-c", script], capture_output=True, text=True, timeout=60, check=False)
+    assert result.returncode == 0, result.stderr
+    assert "virtual size: 4 GiB" in result.stdout
+    assert "clean-start" in result.stdout
+    # the last listing, after the delete, shows no snapshot line after the final info block
+    assert result.stdout.count("clean-start") == 1
+
+
+@pytest.mark.skipif(shutil.which("openssl") is None, reason="openssl is not installed")
+def test_hsm_part_a_signs_verifies_and_fails_on_a_changed_message(tmp_path):
+    body = text("Hardware-Security-Modules-What-They-Are-and-Building-Your-Own-with-pico2hsm")
+    block = _first(body, "bash", "ecparam")
+    steps = block.replace("mkdir -p ~/hsmlab && cd ~/hsmlab", f"cd {tmp_path}").split("# 4.")[0]  # up to the first verify
+    ok = subprocess.run(["bash", "-eu", "-c", steps], capture_output=True, text=True, timeout=60, check=False)
+    assert ok.returncode == 0, ok.stderr
+    assert "Verified OK" in ok.stdout + ok.stderr
+    bad = subprocess.run(
+        ["bash", "-c", f"cd {tmp_path} && echo tamper >> msg.txt && openssl dgst -sha256 -verify pub.der -keyform DER -signature sig.bin msg.txt"],
+        capture_output=True,
+        text=True,
+        timeout=60,
+        check=False,
+    )
+    assert bad.returncode != 0
+
+
+@pytest.mark.skipif(shutil.which("ansible-playbook") is None, reason="ansible-playbook is not installed")
+def test_ansible_playbook_is_idempotent_and_the_bad_task_is_not(tmp_path):
+    body = text("Ansible-Configuration-Management-Versus-Provisioning")
+    recap = re.compile(r"ok=(\d+)\s+changed=(\d+)")
+    inventory = next(b for b in blocks(body, "ini") if "[lab]" in b)
+    playbook = next(b for b in blocks(body, "yaml") if "Make a small config directory" in b)
+    bad = next(b for b in re.findall(r"cat > bad\.yml <<'EOF'\n(.*?)\nEOF", "\n".join(blocks(body, "bash")), re.DOTALL))
+    (tmp_path / "inventory.ini").write_text(inventory, encoding="utf-8")
+    (tmp_path / "site.yml").write_text(playbook, encoding="utf-8")
+    (tmp_path / "bad.yml").write_text(bad, encoding="utf-8")
+
+    def run(play: str) -> tuple[int, int]:
+        out = subprocess.run(["ansible-playbook", "-i", "inventory.ini", play], cwd=tmp_path, capture_output=True, text=True, timeout=120, check=False)
+        assert out.returncode == 0, out.stdout + out.stderr
+        m = recap.search(out.stdout)
+        assert m, out.stdout
+        return int(m.group(1)), int(m.group(2))
+
+    assert run("site.yml") == (3, 3)
+    assert run("site.yml") == (3, 0)
+    assert run("bad.yml")[1] == 1 and run("bad.yml")[1] == 1
+    assert (tmp_path / "sandbox" / "bad.conf").read_text(encoding="utf-8").count("retries = 3") == 2

+ 0 - 143
tests/test_memory_forensics_lesson.py

@@ -1,143 +0,0 @@
-# SPDX-License-Identifier: Apache-2.0
-"""The memory forensics lesson: it is registered, honest about what was run, and safe to follow.
-
-docs/wiki/Memory-Forensics-Acquiring-RAM-and-Analyzing-It-with-Volatility-3.md teaches acquiring a lab VM's RAM and
-reading it with Volatility 3. A broken link, a missing registration, a claim with no status, a real address, or a
-command that bridges the lab guest onto a real network would each teach the wrong thing.
-"""
-
-import re
-from pathlib import Path
-
-ROOT = Path(__file__).resolve().parent.parent
-WIKI = ROOT / "docs" / "wiki"
-NAME = "Memory-Forensics-Acquiring-RAM-and-Analyzing-It-with-Volatility-3"
-PAGE = WIKI / f"{NAME}.md"
-FENCE = re.compile(r"^[ ]*```(\w*)\n(.*?)^[ ]*```$", re.MULTILINE | re.DOTALL)
-LINK = re.compile(r"\]\(([A-Za-z0-9_-]+)\.md(?:#[^)]*)?\)")
-ADDR = re.compile(r"\b(?:\d{1,3}\.){3}\d{1,3}\b")
-STATUS_WORDS = ("Read", "Observed", "General knowledge", "**est.**")
-
-
-def text() -> str:
-    return PAGE.read_text(encoding="utf-8")
-
-
-def register_rows(body: str) -> list[list[str]]:
-    reg = body.split("## Claims register")[1]
-    rows = [line for line in reg.splitlines() if line.startswith("|") and not line.startswith("|---")]
-    return [[c.strip() for c in r.strip("|").split("|")] for r in rows[1:]]
-
-
-def rows_missing_status(body: str) -> list[str]:
-    return [r[0] for r in register_rows(body) if not any(w in r[-1] for w in STATUS_WORDS)]
-
-
-def bridged_lines(commands: str) -> list[str]:
-    return [l for l in commands.splitlines() if re.search(r"-(nic|netdev|net)\s+(bridge|tap)|\bbridge=", l)]
-
-
-def test_the_page_says_what_was_and_was_not_run():
-    body = text()
-    assert body.startswith("# Memory forensics: acquiring RAM")
-    assert "Status: unverified draft" in body
-    assert "**Not run:**" in body and "2026-11-07" in body
-    assert "Volatility 3 2.28.2" in body
-
-
-def test_every_linked_wiki_page_exists():
-    links = set(LINK.findall(text()))
-    assert len(links) >= 4, "the guard collected too few links"
-    assert not sorted(t for t in links if not (WIKI / f"{t}.md").exists())
-
-
-def test_the_lesson_is_registered_in_the_digital_forensics_subgroup():
-    nav = (WIKI / "_nav.yaml").read_text(encoding="utf-8")
-    line = nav.split(f"page: {NAME},")[1].split("\n")[0]
-    assert 'status: "draft"' in line and 'subgroup: "Digital forensics"' in line
-    for special in ("Contents.md", "_Sidebar.md", "Reading-Order.md"):
-        assert f"{NAME}.md" in (WIKI / special).read_text(encoding="utf-8"), special
-    rows = [l for l in (WIKI / "Glossary.md").read_text(encoding="utf-8").splitlines() if f"{NAME}.md" in l]
-    assert len(rows) >= 4
-
-
-def test_glossary_rows_point_at_real_headings():
-    heads = set()
-    for h in re.findall(r"^#+ (.+)$", text(), re.MULTILINE):
-        heads.add(re.sub(r"[^a-z0-9-]", "", h.lower().replace(" ", "-")))
-    anchors = set()
-    for line in (WIKI / "Glossary.md").read_text(encoding="utf-8").splitlines():
-        anchors.update(re.findall(rf"{NAME}\.md#([a-z0-9-]+)", line))
-    assert anchors, "the guard collected nothing"
-    assert anchors <= heads, sorted(anchors - heads)
-
-
-def test_no_addresses_except_loopback_and_no_em_dashes():
-    body = text()
-    found = set(ADDR.findall(body))
-    assert found == {"127.0.0.1"}, found
-    assert "—" not in body
-
-
-def test_the_callsign_and_machine_names_are_placeholders():
-    body = text()
-    assert "N0TST" in body
-    assert r"local-hostname: lab\n" in body
-
-
-def test_the_guest_is_never_bridged_onto_a_real_network():
-    cmds = "\n".join(b for t, b in FENCE.findall(text()) if t == "bash")
-    assert "-nic user" in cmds and "hostfwd=tcp:127.0.0.1" in cmds, "the guard collected nothing"
-    assert not bridged_lines(cmds)
-
-
-def test_the_bridge_guard_bites():
-    assert bridged_lines("qemu-system-x86_64 -nic bridge,br=br0")
-    assert not bridged_lines("qemu-system-x86_64 -nic user,model=virtio-net-pci")
-
-
-def test_the_checksum_is_checked_before_the_first_boot():
-    body = text()
-    assert body.index("sha512sum -c sums") < body.index("qemu-system-x86_64 -accel kvm")
-    assert "do not boot the image" in body
-
-
-def test_every_claims_register_row_has_a_status():
-    rows = register_rows(text())
-    assert len(rows) >= 20, "the guard collected too few rows"
-    assert not rows_missing_status(text())
-
-
-def test_the_register_guard_bites():
-    bad = "## Claims register\n\n| Claim | Source | Status |\n|---|---|---|\n| X | y | maybe |\n"
-    assert rows_missing_status(bad) == ["X"]
-
-
-def test_license_and_version_are_stated_with_dates():
-    body = text()
-    assert "Volatility Software License, Version 1.0" in body
-    assert "2.28.2" in body and "2026-09-17" in body
-
-
-def test_the_page_names_the_plugins_it_ran():
-    body = text()
-    for plugin in ("linux.pslist.PsList", "linux.psscan.PsScan", "linux.sockstat.Sockstat", "linux.malware.malfind.Malfind", "windows.psscan.PsScan", "windows.netscan.NetScan"):
-        assert plugin in body, plugin
-
-
-def test_siblings_and_firmware_lessons_are_linked_and_the_pages_exist():
-    # Was: siblings are plain text until they merge. They are on main now, so each is a link to a page that exists.
-    body = re.sub(r"<!-- BEGIN GENERATED .*?<!-- END GENERATED [^>]*-->", "", text(), flags=re.DOTALL)
-    links = set(LINK.findall(body))
-    for prefix in (
-        "Digital-Forensics-Foundations",
-        "Disk-Forensics",
-        "Network-Log-and-Timeline-Forensics",
-        "DFIR-Toolkits",
-        "Device-Firmware-Security",
-        "Open-Firmware",
-    ):
-        hits = [t for t in links if t.startswith(prefix)]
-        assert hits, prefix
-        assert all((WIKI / f"{t}.md").exists() for t in hits), prefix
-    assert "plain text until they merge" not in body

+ 0 - 131
tests/test_network_log_timeline_forensics_lesson.py

@@ -1,131 +0,0 @@
-# SPDX-License-Identifier: Apache-2.0
-"""The network, log and timeline forensics lesson: registered, honest about what was run, safe to follow (issue #477).
-
-docs/wiki/Network-Log-and-Timeline-Forensics-Packet-Captures-Logs-and-Plaso.md teaches evidence handling for a capture,
-log trust, the time zone mistake and a plaso timeline. A broken link, a missing registration, a claim with no status, a real
-address or callsign, or a link to a sibling lesson that does not exist yet would each mislead a reader.
-"""
-
-import re
-from pathlib import Path
-
-from wikitext import page_text
-
-ROOT = Path(__file__).resolve().parent.parent
-WIKI = ROOT / "docs" / "wiki"
-NAME = "Network-Log-and-Timeline-Forensics-Packet-Captures-Logs-and-Plaso"
-PAGE = WIKI / f"{NAME}.md"
-LINK = re.compile(r"\]\(([A-Za-z0-9_-]+)\.md(?:#[^)]*)?\)")
-ADDR = re.compile(r"\b(?:\d{1,3}\.){3}\d{1,3}\b")
-LAB_ADDR = re.compile(r"\b(?:10\.89\.0\.\d{1,3}|0\.0\.0\.0)\b")
-STATUS_WORDS = ("Read", "Run", "Observed", "**est.**")
-
-
-def text() -> str:
-    return page_text(PAGE)
-
-
-def register_rows(body: str) -> list[list[str]]:
-    reg = body.split("## Claims register")[1]
-    rows = [line for line in reg.splitlines() if line.startswith("|") and not line.startswith("|---")]
-    return [[c.strip() for c in r.strip("|").split("|")] for r in rows[1:]]
-
-
-def rows_missing_status(body: str) -> list[str]:
-    return [r[0] for r in register_rows(body) if not any(w in r[-1] for w in STATUS_WORDS)]
-
-
-def non_lab_addresses(body: str) -> list[str]:
-    return [a for a in ADDR.findall(body) if not LAB_ADDR.fullmatch(a)]
-
-
-def heading_slugs(body: str) -> set[str]:
-    return {re.sub(r"[^a-z0-9 -]", "", h.lower()).replace(" ", "-") for h in re.findall(r"^#+ (.+)$", body, re.MULTILINE)}
-
-
-def test_the_page_exists_and_says_what_was_and_was_not_run():
-    body = text()
-    assert body.startswith("# Network, log and timeline forensics")
-    assert "Status: unverified draft" in body
-    assert "2026-11-07" in body
-    assert "Not verified, plainly" in body
-    assert "What I ran and what failed" in body
-
-
-def test_every_linked_wiki_page_exists_and_no_sibling_lesson_is_linked_early():
-    links = set(LINK.findall(text()))
-    assert len(links) >= 6, "the guard collected too few links"
-    assert not sorted(t for t in links if not (WIKI / f"{t}.md").exists())
-    # The sibling forensics lessons exist now and are linked; the check above fails on a dead link.
-
-
-def test_the_lesson_is_registered_everywhere():
-    nav = (WIKI / "_nav.yaml").read_text(encoding="utf-8")
-    entry = nav.split(f"page: {NAME},")[1].split("\n")[0]
-    assert 'status: "draft"' in entry
-    assert 'subgroup: "Digital forensics"' in entry
-    for special in ("Contents.md", "_Sidebar.md", "Reading-Order.md"):
-        assert f"{NAME}.md" in (WIKI / special).read_text(encoding="utf-8"), special
-    rows = [l for l in (WIKI / "Glossary.md").read_text(encoding="utf-8").splitlines() if f"{NAME}.md" in l]
-    assert len(rows) >= 5, "expected glossary rows for pcap, tshark, follow stream, plaso, super timeline"
-
-
-def test_glossary_rows_point_at_real_headings():
-    heads = heading_slugs(text())
-    anchors = set()
-    for line in (WIKI / "Glossary.md").read_text(encoding="utf-8").splitlines():
-        anchors.update(re.findall(rf"{NAME}\.md#([a-z0-9-]+)", line))
-    assert anchors, "the guard collected nothing"
-    assert anchors <= heads, sorted(anchors - heads)
-
-
-def test_in_page_anchors_point_at_real_headings():
-    body = text()
-    heads = heading_slugs(body)
-    own = set(re.findall(r"\]\(#([a-z0-9-]+)\)", body))
-    assert own, "the guard collected nothing"
-    assert own <= heads, sorted(own - heads)
-
-
-def test_no_em_dashes_and_only_lab_addresses():
-    body = text()
-    assert "—" not in body
-    assert not non_lab_addresses(body), non_lab_addresses(body)
-    assert non_lab_addresses("host 192.0.2.7"), "the address guard does not bite"
-
-
-def test_no_callsign_style_placeholders_or_real_secrets():
-    body = text()
-    assert "hunter2-lab" in body, "the invented lab password should be marked as invented"
-    assert "invented" in body
-
-
-def test_every_claims_register_row_has_a_status():
-    body = text()
-    rows = register_rows(body)
-    assert len(rows) >= 15, "the guard collected too few rows"
-    assert not rows_missing_status(body)
-
-
-def test_the_status_guard_bites():
-    bad = "## Claims register\n\n| Claim | Source | Status |\n|---|---|---|\n| X | Y | trust me |\n"
-    assert rows_missing_status(bad) == ["X"]
-
-
-def test_the_time_zone_lesson_names_both_runs_and_the_offset():
-    body = text()
-    assert "--timezone America/New_York" in body
-    assert "2026-11-07T10:49:52+00:00" in body and "2026-11-07T15:49:52+00:00" in body
-    assert "7 minutes 2 seconds" in body
-
-
-def test_the_plaso_facts_are_dated_and_use_the_real_parser_names():
-    body = text()
-    assert "20261027" in body and "Apache-2.0" in body
-    assert "text/apache_access" in body and "text/syslog_traditional" in body
-
-
-def test_the_law_section_says_not_legal_advice_and_keeps_to_own_network():
-    body = text()
-    assert "not legal advice" in body
-    assert "own computer" in body or "container network you create" in body

+ 0 - 188
tests/test_open_firmware_lesson.py

@@ -1,188 +0,0 @@
-# SPDX-License-Identifier: Apache-2.0
-"""The open firmware lesson: registered, dated, honest about what was run, and read-only.
-
-docs/wiki/Open-Firmware-and-Trustworthy-Hardware-...-Disabled.md reports what four hardware vendors claim about
-the Intel Management Engine. A claim with no date or status, a vendor named in the table but missing from the
-vendor section, a flashing command, an affiliate link, a real address or a stale registration would each teach
-the wrong thing.
-"""
-
-import re
-import textwrap
-from pathlib import Path
-
-ROOT = Path(__file__).resolve().parent.parent
-WIKI = ROOT / "docs" / "wiki"
-NAME = "Open-Firmware-and-Trustworthy-Hardware-coreboot-Heads-Nitrokey-and-Vendors-That-Ship-the-Intel-ME-Disabled"
-PAGE = WIKI / f"{NAME}.md"
-FENCE = re.compile(r"^[ ]*```(\w*)\n(.*?)^[ ]*```$", re.MULTILINE | re.DOTALL)
-LINK = re.compile(r"\]\(([A-Za-z0-9_-]+)\.md(?:#[^)]*)?\)")
-ADDR = re.compile(r"\b(?:\d{1,3}\.){3}\d{1,3}\b")
-STATUS_WORDS = ("Read", "Observed", "General knowledge", "**est.**", "**not verified**")
-VENDORS = ("Novacustom", "System76", "Purism", "Tuxedo")
-WRITE_TOKENS = re.compile(r"\bsudo\b|\bflashrom\b|\bifdtool\b|\bme_cleaner\b|\bnvramtool\b|\bdd\b|\bchmod\b|>\s*/(?:sys|dev|boot)", re.IGNORECASE)
-AFFILIATE = re.compile(r"[?&](ref|aff|affiliate|utm_[a-z]+|tag|partner)=", re.IGNORECASE)
-
-
-def text() -> str:
-    return PAGE.read_text(encoding="utf-8")
-
-
-def blocks(tag: str) -> list[str]:
-    return [textwrap.dedent(b) for t, b in FENCE.findall(text()) if t == tag]
-
-
-def register_rows(body: str) -> list[list[str]]:
-    reg = body.split("## Claims register")[1].split("\n## ")[0]
-    rows = [line for line in reg.splitlines() if line.startswith("|") and not line.startswith("|---")]
-    return [[c.strip() for c in r.strip("|").split("|")] for r in rows[1:]]
-
-
-def rows_missing_status(body: str) -> list[str]:
-    return [r[0] for r in register_rows(body) if not any(w in r[-1] for w in STATUS_WORDS)]
-
-
-def unsafe_lines(commands: str) -> list[str]:
-    return [l for l in commands.splitlines() if WRITE_TOKENS.search(l)]
-
-
-def vendor_section(body: str, vendor: str) -> str:
-    start = body.index(f"### {vendor}")
-    first_line_end = body.index("\n", start) + 1
-    rest = body[first_line_end:]
-    nxt = re.search(r"^#{2,3} ", rest, re.MULTILINE)
-    return body[start : first_line_end + (nxt.start() if nxt else len(rest))]
-
-
-def test_the_page_exists_and_says_what_was_and_was_not_run():
-    body = text()
-    assert body.startswith("# Open firmware and trustworthy hardware")
-    assert "> **Status: unverified draft." in body
-    assert "Nothing was flashed" in body
-    assert "**Not run:**" in body and "2026-11-07" in body
-    assert "Not verified, plainly" in body
-
-
-def test_every_linked_wiki_page_exists():
-    links = set(LINK.findall(text()))
-    assert len(links) >= 5, "the guard collected too few links"
-    missing = sorted(t for t in links if not (WIKI / f"{t}.md").exists())
-    assert not missing, missing
-
-
-def test_the_lesson_is_registered_everywhere():
-    nav = (WIKI / "_nav.yaml").read_text(encoding="utf-8")
-    entry = nav.split(f"page: {NAME},")[1].split("\n")[0]
-    assert 'status: "draft"' in entry
-    for special in ("Contents.md", "_Sidebar.md", "Reading-Order.md"):
-        assert f"{NAME}.md" in (WIKI / special).read_text(encoding="utf-8"), special
-    rows = [l for l in (WIKI / "Glossary.md").read_text(encoding="utf-8").splitlines() if f"{NAME}.md" in l]
-    assert len(rows) >= 6, "expected glossary rows for the new terms"
-
-
-def test_glossary_rows_point_at_real_headings():
-    heads = {re.sub(r"[^a-z0-9 -]", "", h.lower()).strip().replace(" ", "-") for h in re.findall(r"^#+ (.+)$", text(), re.MULTILINE)}
-    anchors = set()
-    for line in (WIKI / "Glossary.md").read_text(encoding="utf-8").splitlines():
-        anchors.update(re.findall(rf"{NAME}\.md#([a-z0-9-]+)", line))
-    assert anchors, "the guard collected nothing"
-    assert anchors <= heads, sorted(anchors - heads)
-
-
-def test_no_em_dashes_no_addresses_and_no_affiliate_links():
-    body = text()
-    assert "—" not in body and "–" not in body
-    assert not ADDR.findall(body), ADDR.findall(body)
-    urls = re.findall(r"\]\((https?://[^)]+)\)", body)
-    assert len(urls) >= 20, "the guard collected too few links"
-    assert not [u for u in urls if AFFILIATE.search(u)]
-
-
-def test_the_guards_bite():
-    assert ADDR.findall("host 192.0.2.7")
-    assert AFFILIATE.search("https://example.com/p?ref=abc")
-    assert not AFFILIATE.search("https://example.com/p")
-
-
-def test_there_are_no_flashing_or_write_commands_in_any_code_block():
-    cmds = "\n".join(b for _, b in FENCE.findall(text()))
-    assert "curl" in cmds and "fwupdmgr" in cmds, "the guard collected nothing"
-    assert not unsafe_lines(cmds)
-
-
-def test_the_write_guard_bites():
-    assert unsafe_lines("sudo flashrom -p internal -w rom.bin")
-    assert unsafe_lines("python me_cleaner.py -S image.bin")
-    assert unsafe_lines("echo 1 > /sys/class/x")
-    assert not unsafe_lines("cat /sys/class/tpm/tpm0/tpm_version_major")
-
-
-def test_each_vendor_has_a_section_with_a_firmware_and_an_me_line():
-    body = text()
-    for vendor in VENDORS:
-        sec = vendor_section(body, vendor)
-        assert "Firmware" in sec or "Tuxedo" in vendor, vendor
-        assert "ME" in sec, vendor
-    assert "I could not verify a claim" in vendor_section(body, "Tuxedo Computers")
-
-
-def test_the_vendor_section_helper_bites():
-    sample = "### A\nFirmware ME\n### B\nother\n"
-    assert "Firmware ME" in vendor_section(sample, "A")
-    assert "other" not in vendor_section(sample, "A")
-
-
-def test_the_four_me_words_and_the_dasharo_modes_are_named():
-    body = text()
-    for word in ("Absent", "Neutralized", "Soft-disabled", "HAP-disabled"):
-        assert f"**{word}**" in body, word
-    for mode in ("Enabled", "Disabled (Soft)", "Disabled (HAP)"):
-        assert mode in body, mode
-
-
-def test_every_vendor_page_is_dated_in_the_register():
-    body = text()
-    assert body.count("2026-11-07") >= 8
-    reg = body.split("## Claims register")[1]
-    for vendor in VENDORS:
-        assert vendor in reg, vendor
-
-
-def test_every_claims_register_row_has_a_status():
-    rows = register_rows(text())
-    assert len(rows) >= 35, "the guard collected too few rows"
-    assert not rows_missing_status(text())
-
-
-def test_the_register_guard_bites():
-    bad = "## Claims register\n\n| Claim | Source | Status |\n|---|---|---|\n| X | y | maybe |\n"
-    assert rows_missing_status(bad) == ["X"]
-
-
-def test_the_heads_key_table_matches_the_heads_prerequisites_wording():
-    body = text()
-    assert "Heads does NOT support FIDO2 or U2F" in body
-    assert "OpenPGP only" in body
-    for key in ("YubiKey 5 Series", "Nitrokey Pro 2", "Nitrokey Storage 2", "Nitrokey 3", "Librem Key"):
-        assert key in body, key
-
-
-def test_the_page_ends_by_linking_the_firmware_and_hardware_keys_lessons():
-    body = text()  # the page file ends with its own text: the navigation block is added when the wiki is published (issue #521)
-    tail = body.split("## Where this goes next")[1]
-    for target in ("Device-Firmware-Security-Intel-ME-AMD-PSP-MINIX-and-Kernel-Design", "Hardware-Security-Keys-YubiKey-Nitrokey-Smart-Cards-and-PIV"):
-        assert f"]({target}.md)" in tail, target
-        assert (WIKI / f"{target}.md").exists(), target
-    assert "no link" not in tail and "not written yet" not in text()
-    assert "Hardware-Security-Keys-YubiKey-Nitrokey-Smart-Cards-and-PIV.md" in text()
-
-
-def test_tuxedo_is_a_dated_user_selectable_option_on_one_model_not_a_shipped_default():
-    body = text()
-    sec = vendor_section(body, "Tuxedo Computers")
-    assert "2018-03-14" in sec and "InfinityBook Pro 13" in sec
-    assert "TUXEDO-disables-Intels-Management-Engine.tuxedo" in sec
-    assert "Ask Tuxedo in writing" not in body
-    assert "ships with the ME disabled" not in body.replace('not "ships with the ME disabled"', "")
-    reg_rows = [r for r in register_rows(body) if "press release" in r[0] and "Tuxedo" in r[0]]
-    assert reg_rows and "2018-03-14" in reg_rows[0][0] and "TUXEDO-disables" in reg_rows[0][1]

+ 0 - 167
tests/test_vm_hypervisors_lesson.py

@@ -1,167 +0,0 @@
-# SPDX-License-Identifier: Apache-2.0
-"""The virtual machines and hypervisors lesson: it is registered, honest about what was run, and safe to follow.
-
-docs/wiki/Virtual-Machines-Hypervisors-Desktop-and-Datacenter-Options.md teaches a first VM, network modes and a
-dated account of the VMware licensing changes. A broken link, a missing registration, a bridged-network command in a
-lab page, a real address, or a vendor claim with no status would each teach the wrong thing.
-"""
-
-import re
-import shutil
-import subprocess
-import textwrap
-from pathlib import Path
-
-import pytest
-
-ROOT = Path(__file__).resolve().parent.parent
-WIKI = ROOT / "docs" / "wiki"
-NAME = "Virtual-Machines-Hypervisors-Desktop-and-Datacenter-Options"
-PAGE = WIKI / f"{NAME}.md"
-FENCE = re.compile(r"^[ ]*```(\w*)\n(.*?)^[ ]*```$", re.MULTILINE | re.DOTALL)
-LINK = re.compile(r"\]\(([A-Za-z0-9_-]+)\.md(?:#[^)]*)?\)")
-ADDR = re.compile(r"\b(?:\d{1,3}\.){3}\d{1,3}\b")
-STATUS_WORDS = ("Read", "Observed", "Page read", "General knowledge", "**est.**")
-
-
-def text() -> str:
-    return PAGE.read_text(encoding="utf-8")
-
-
-def blocks(tag: str) -> list[str]:
-    return [textwrap.dedent(b) for t, b in FENCE.findall(text()) if t == tag]
-
-
-def register_rows(body: str) -> list[list[str]]:
-    reg = body.split("## Claims register")[1]
-    rows = [line for line in reg.splitlines() if line.startswith("|") and not line.startswith("|---")]
-    return [[c.strip() for c in r.strip("|").split("|")] for r in rows[1:]]
-
-
-def rows_missing_status(body: str) -> list[str]:
-    return [r[0] for r in register_rows(body) if not any(r[-1].startswith(w) or w in r[-1] for w in STATUS_WORDS)]
-
-
-def unsafe_network_lines(commands: str) -> list[str]:
-    return [l for l in commands.splitlines() if re.search(r"-(nic|netdev|net)\s+(bridge|tap)|\bbridge=|--network\s+bridged|nic\d?\s+bridged", l)]
-
-
-def test_the_page_exists_and_says_what_was_and_was_not_run():
-    body = text()
-    assert body.startswith("# Virtual machines for beginners")
-    assert "Status: unverified draft" in body
-    assert "no hypervisor was installed and no guest was booted" in body
-    assert "**Not run:**" in body and "2026-10-31" in body
-    assert "Not verified, plainly" in body
-
-
-def test_every_linked_wiki_page_exists():
-    links = set(LINK.findall(text()))
-    assert len(links) >= 8, "the guard collected too few links"
-    missing = sorted(t for t in links if not (WIKI / f"{t}.md").exists())
-    assert not missing, missing
-
-
-def test_the_lesson_is_registered_everywhere():
-    nav = (WIKI / "_nav.yaml").read_text(encoding="utf-8")
-    assert f"page: {NAME}," in nav and 'status: "draft"' in nav.split(f"page: {NAME},")[1].split("\n")[0]
-    for special in ("Contents.md", "_Sidebar.md", "Reading-Order.md"):
-        assert f"{NAME}.md" in (WIKI / special).read_text(encoding="utf-8"), special
-    rows = [l for l in (WIKI / "Glossary.md").read_text(encoding="utf-8").splitlines() if f"{NAME}.md" in l]
-    assert len(rows) >= 5, "expected glossary rows for the new terms"
-
-
-def test_glossary_rows_point_at_real_headings():
-    heads = {re.sub(r"[^a-z0-9 -]", "", h.lower()).strip().replace(" ", "-") for h in re.findall(r"^#+ (.+)$", text(), re.MULTILINE)}
-    heads = {re.sub(r"[^a-z0-9-]", "", h.replace(" ", "-")) for h in heads}
-    anchors = set()
-    for line in (WIKI / "Glossary.md").read_text(encoding="utf-8").splitlines():
-        anchors.update(re.findall(rf"{NAME}\.md#([a-z0-9-]+)", line))
-    assert anchors, "the guard collected nothing"
-    assert anchors <= heads, sorted(anchors - heads)
-
-
-def test_existing_pages_that_assume_a_vm_or_linux_host_link_the_lesson():
-    users = [p.name for p in WIKI.glob("*.md") if p.name != PAGE.name and f"{NAME}.md" in p.read_text(encoding="utf-8")]
-    skip = {"Glossary.md", "_Sidebar.md", "Reading-Order.md", "Contents.md"}
-    inbound = [u for u in users if u not in skip]
-    assert len(inbound) >= 4, inbound
-
-
-def test_no_addresses_except_loopback_and_no_em_dashes():
-    body = text()
-    found = set(ADDR.findall(body))
-    assert found <= {"127.0.0.1"}, found
-    assert "127.0.0.1" in found, "the guard collected nothing"
-    assert "—" not in body
-
-
-def test_the_address_guard_bites():
-    assert set(ADDR.findall("ping 192.0.2.7")) != {"127.0.0.1"}
-
-
-def test_the_lab_commands_never_bridge_the_guest_onto_a_real_network():
-    cmds = "\n".join(blocks("bash"))
-    assert "qemu-system-x86_64" in cmds and "-nic user" in cmds, "the guard collected nothing"
-    assert not unsafe_network_lines(cmds)
-
-
-def test_the_network_guard_bites():
-    assert unsafe_network_lines("qemu-system-x86_64 -nic bridge,br=br0")
-    assert unsafe_network_lines("qemu-system-x86_64 -netdev tap,id=n0")
-    assert not unsafe_network_lines("qemu-system-x86_64 -nic user,model=virtio-net-pci")
-
-
-def test_the_safety_rule_names_the_three_core_steps():
-    rule = text().split("## The safety rule for malware and recon labs")[1].split("## Free path")[0]
-    assert "Isolate the network first" in rule
-    assert "Snapshot a clean state first" in rule
-    assert "Never bridge a hostile VM onto your home LAN" in rule
-
-
-def test_the_checksum_step_comes_before_the_first_boot():
-    body = text()
-    assert body.index("sha256sum -c") < body.index("qemu-system-x86_64 -accel kvm")
-    assert "do not boot an image that fails its check" in body
-    digest = re.search(r"`([0-9a-f]{64})`", body)
-    assert digest, "the example checksum is missing"
-
-
-def test_every_claims_register_row_has_a_status():
-    rows = register_rows(text())
-    assert len(rows) >= 25, "the guard collected too few rows"
-    assert not rows_missing_status(text())
-
-
-def test_the_register_guard_bites():
-    bad = "## Claims register\n\n| Claim | Source | Status |\n|---|---|---|\n| X | y | maybe |\n"
-    assert rows_missing_status(bad) == ["X"]
-
-
-def test_the_vmware_account_is_dated_and_cites_vendor_and_news_sources():
-    body = text()
-    section = body.split("## VMware after Broadcom: a dated account")[1].split("## The bigger options")[0]
-    for date in ("2023-11-22", "2023-12-11", "May 2024", "2024-11-11", "2025-03-10", "2025-04-10"):
-        assert date in section, date
-    for needle in ("BBC News", "Ars Technica", "release notes", "**est.**"):
-        assert needle in section, needle
-    assert "not verified" in section.lower()
-    assert "Read" in section
-
-
-def test_the_page_names_the_apple_options_from_apples_own_pages():
-    body = text()
-    assert "Virtualization framework" in body and "macOS 11.0" in body
-    assert "`container`" in body and "macOS 26" in body
-
-
-@pytest.mark.skipif(shutil.which("qemu-img") is None, reason="qemu-img is not installed")
-def test_exercise_3_runs_and_the_snapshot_round_trips(tmp_path):
-    block = next(b for b in blocks("bash") if "qemu-img create" in b)
-    script = block.replace("cd ~/vmlab", f"cd {tmp_path}")
-    result = subprocess.run(["bash", "-eu", "-c", script], capture_output=True, text=True, timeout=60, check=False)
-    assert result.returncode == 0, result.stderr
-    assert "virtual size: 4 GiB" in result.stdout
-    assert "clean-start" in result.stdout
-    # the last listing, after the delete, shows no snapshot line after the final info block
-    assert result.stdout.count("clean-start") == 1