9b762c146f7a44a3bdc783cdd202356fc163b8fb
braney
  Wed Sep 16 12:43:32 2026 -0700
docent: one targetConf.js for the target, the hg.conf, the central and the account, refs #37892

docent.js and tests/preflight.js had grown a second and then a third copy of the
same lookups.  That is exactly the pair that must not drift: preflight checks the
fixtures for the server the RUN will drive, so a run that resolved its target, its
hg.conf, its hgcentral or its account even slightly differently would be checked
against the wrong machine, and the mismatch would show up as a green preflight in
front of a red suite.

targetConf.js answers the four questions in order, each from the one before:

resolveTarget   a `target:` (or DOCENT_TARGET) -> the .../cgi-bin URL to drive
hgConfFor       that URL -> the hg.conf it reads, if the server is on this box
centralDbFor    that conf -> which hgcentral it uses
loginLookup     that central -> the account to sign in with

Nothing in it opens a browser or the network, which is why preflight can ask all
four in the seconds before a run.

loginLookup returns the facts plus, when the account cannot be used, ONE sentence
saying why.  That sentence is the substantive half and is now written once: the
step throws it with a `login:` prefix, preflight prints it on the MISSING line.
Each caller still phrases its own success line, since one logs and the other
prints a fixture row.  No password crosses that boundary to anything that prints.

248 lines net out of the two programs, 197 into the module.

docent.js is no longer a single file, and three places now say so: its own require,
the Run section of README.md, and docent.mk, whose mp4 rule gains targetConf.js as
a prerequisite -- a change there changes what a tour renders, so it has to rebuild
one.  Nothing in the tree or in ~/docentTours copies docent.js; they all reference
it where it sits, with targetConf.js beside it.

Measured before and after, with no other change: preflight resolves the same
account, central and conf for genome-test, hgwdev-braney, a ts park on 48087 and
hgwbeta (which correctly has no section); tests/ is 18 of 18 with the derive
baselines matching; tests/regress preflights 14 fixtures for 67 scripts.

diff --git src/hg/utils/docent/README.md src/hg/utils/docent/README.md
index c12dc9bf3ba..2186b57f549 100644
--- src/hg/utils/docent/README.md
+++ src/hg/utils/docent/README.md
@@ -19,30 +19,37 @@
 
 The verbs deliberately encode *browser mechanics* rather than selectors: `convert:`
 knows that the Hide-defaults checkbox reverts when the Assembly menu reloads,
 `track: {clinvar: pack}` asks trackDb which containers and checkboxes that implies, and
 `mouseover:` knows that a lifted track's DOM id gains a per-run `hub_<n>_` prefix. The author writes
 intent; the renderer deals with the UI.
 
 ## Run
 
 ```
 PW=/hive/groups/browser/uiTest/pw
 PLAYWRIGHT_BROWSERS_PATH=$PW/browsers NODE_PATH=$PW/node_modules \
   node docent.js AP1.docent.yaml
 ```
 
+`docent.js` is not a single file: it requires `targetConf.js` from beside it, which
+answers where a run is pointed (`target:` and `DOCENT_TARGET`), which `hg.conf` that
+server reads, which hgcentral that names, and which account a `login:` step signs in
+with. `tests/preflight.js` requires the same module, which is the point of it being one:
+the fixture check has to resolve all four exactly the way the run will. Copy the pair, or
+run `docent.js` where it sits.
+
 Needs `playwright`, `js-yaml`, and `ffmpeg`. At UCSC these live in one pinned shared
 install at `/hive/groups/browser/uiTest/pw` (`browsers` for Chromium, `node_modules`
 for the modules), which every browser-driving test in the tree uses; its `README.md`
 records the pinned versions. Point the two variables above anywhere you have them.
 
 Outputs, relative to the script's own directory:
 
 - mp4 → `../<base>.mp4` (override with `mp4:` or a second argument)
 - stills → `stills/<base>/<name>.png` (override with `stills:`)
 - sessions → `sessions/<base>/<name>.txt` (override the parent with `sessions:`)
 
 `docent.mk` in this directory has the make rules — include it from a project that keeps
 a set of scripts and it rebuilds only the ones whose source changed. See the usage
 comment at the top of that file.