4697bbddd881c72cccb85b9ff0aacd769396b9d0
braney
  Thu Sep 10 07:34:35 2026 -0700
docent: record what evidence each regression test has, and count it

A regression test written after the fix asserts the right answer, but nobody
has watched it fail for the reason it exists, and a loose assertion in that
state is indistinguishable from no test at all. Four of the 37 scripts here
have actually been watched to flip. That was recorded only as prose in each
script's header, so answering "how many of these are real regression tests"
meant a grep and a read, and the number could not be quoted.

Every script now carries a top-level `proof:` key, one quoted line per piece
of evidence, `<level> <YYYY-MM-DD> -- <what was seen>`. docent.js reads only
the keys it names off the parsed document, so this costs a run nothing.

tests/proof.js reads them and tallies, wired up as `make proof` in the shared
docentTest.mk. It exits 1 on a malformed line, an unknown level, or a line
left unquoted -- that last one because nearly every note names a ticket and a
bare # in an unquoted YAML scalar silently truncates the sentence at the
ticket number, which is how the first pass of this change lost half its text.

The levels, weakest first: assertion-only, xfail, sandbox-ab, server-flip,
caught-regression. Today that reads 31 / 2 / 0 / 3 / 1.

nightly.sh now records the flips it finds. An xfail that PASSES is the best
evidence this suite produces -- the same server, the same fixtures, the same
script, one real build apart -- and until now it arrived as a red mail and was
thrown away with the log 60 days later. It is appended to
/hive/users/braney/docentNightly/flips.log, one line per script ever, outside
the checkout because --update resets the tree. The mail says what to do with
it. The three flips that already happened (rm38272 2026-09-06, rm36212
2026-09-09, rm38310 2026-09-10) were recovered from the old logs and seeded
there by hand.

Full suite run after the change: 37 scripts, all ok. refs #38252

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

diff --git src/hg/utils/docent/tests/docentTest.mk src/hg/utils/docent/tests/docentTest.mk
index 6a7b08adf14..b74d6158b18 100644
--- src/hg/utils/docent/tests/docentTest.mk
+++ src/hg/utils/docent/tests/docentTest.mk
@@ -1,51 +1,64 @@
 # Shared rules for a directory of Docent tests. Included by tests/makefile and by
 # tests/regress/makefile, so both directories run the same code rather than a copy of it.
 #
 # An including makefile sets, before the include:
 #   DOCENT     path to docent.js from THIS directory     (required)
 #   PREFLIGHT  path to preflight.js from THIS directory  (required)
+#   PROOF      path to proof.js from THIS directory      (default: beside PREFLIGHT)
 #   PARITY     which script `make parity` runs           (default: the first one found)
 #
 # Everything else -- which scripts are tests, which have derive baselines -- comes from
 # what is on disk here, so a new *.docent.yaml is picked up with no edit.
 
 ifndef DOCENT
 $(error include docentTest.mk only after setting DOCENT, e.g. DOCENT = ../docent.js)
 endif
 ifndef PREFLIGHT
 $(error include docentTest.mk only after setting PREFLIGHT, e.g. PREFLIGHT = ./preflight.js)
 endif
 
 PW_DIR ?= /hive/groups/browser/uiTest/pw
 PW_ENV ?= PLAYWRIGHT_BROWSERS_PATH=$(PW_DIR)/browsers NODE_PATH=$(PW_DIR)/node_modules
 T      ?=
 # `make parity` needs one script that is expected to PASS, so an .xfail one is no use as
 # the default. An including makefile can name a better one.
 PASSING := $(filter-out %.xfail,$(patsubst %.docent.yaml,%,$(wildcard *.docent.yaml)))
 PARITY ?= $(firstword $(PASSING))
 TESTS  := $(if $(T),$(addsuffix .docent.yaml,$(T)),$(wildcard *.docent.yaml))
+PROOF  ?= $(dir $(PREFLIGHT))proof.js
 
-.PHONY: test parity clean preflight
+.PHONY: test parity clean preflight proof
 
 # The fixtures the scripts here name but do not contain: saved sessions, hub URLs, the
 # server itself. No browser, so this is seconds, and it is what separates "the fixtures
 # went away" from "a bug came back" -- which are the same red without it. Run it before
 # the suite, and on its own as often as you like.
 preflight:
 	@$(PW_ENV) node $(PREFLIGHT) .
 
+# What evidence each script has that it would catch its bug, and the tally. No browser
+# and no network, so it costs nothing to run and the number can go straight into a commit
+# message or a ticket. It is a separate target and not part of `make test` on purpose: a
+# script with no proof is not a failure, it is a script whose evidence has not been
+# collected yet, and the two must not arrive as the same red.
+#
+# It DOES fail on a malformed or unknown proof line, because a vocabulary nobody enforces
+# turns into free text and free text cannot be counted.
+proof:
+	@$(PW_ENV) node $(PROOF) . $(T)
+
 test:
 	@if [ -z "$(strip $(TESTS))" ]; then \
 	  echo "no *.docent.yaml here -- nothing was tested"; exit 1; fi
 	@fail=0; \
 	for f in $(TESTS); do \
 	  b=$${f%.docent.yaml}; want=0; \
 	  case $$b in *.xfail) want=1;; esac; \
 	  if [ $$want = 1 ]; then printf '=== %s (expected to fail)\n' "$$b"; \
 	  else printf '=== %s\n' "$$b"; fi; \
 	  $(PW_ENV) node $(DOCENT) $$f > $$b.log 2>&1; got=$$?; \
 	  if [ $$got -ne 0 ] && [ $$want -eq 0 ]; then \
 	    echo "  FAILED -- run said:"; sed 's/^/    /' $$b.log; fail=1; \
 	  elif [ $$got -eq 0 ] && [ $$want -eq 1 ]; then \
 	    echo "  FAILED -- this was supposed to fail, and it passed"; fail=1; \
 	  else echo "  ok"; fi; \