checkwright 0.19.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/package.json +2 -2
  2. package/payload/canon-kit/SPEC.md +2 -2
  3. package/payload/canon-kit/checks/check-md-refs.sh +22 -9
  4. package/payload/canon-kit/checks/check-spec-pointer.sh +6 -2
  5. package/payload/context-kit/SPEC.md +13 -6
  6. package/payload/context-kit/lib/toolfloor.sh +1 -1
  7. package/payload/delegation-kit/README.md +2 -1
  8. package/payload/delegation-kit/SPEC.md +207 -35
  9. package/payload/delegation-kit/checks/check-agent-tier-explicit.sh +61 -0
  10. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/bad/agents/silent.md +7 -0
  11. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/bad/args +1 -0
  12. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/bad/expect.txt +1 -0
  13. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/good/agents/explicit-cheap.md +7 -0
  14. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/good/agents/explicit-inherit.md +8 -0
  15. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/good/args +1 -0
  16. package/payload/delegation-kit/gate-tests/check-agent-tier-explicit/good/expect.txt +1 -0
  17. package/payload/delegation-kit/lib/delegation.sh +2 -0
  18. package/payload/delegation-kit/smoke/install.sh +1 -0
  19. package/payload/delegation-kit/templates/agent-execution.md +74 -9
  20. package/payload/gate-sdk/SPEC.md +6 -5
  21. package/payload/gate-sdk/bin/gen-pre-commit.sh +1 -1
  22. package/payload/gate-sdk/bin/run-gates.sh +1 -1
  23. package/payload/gate-sdk/checks/check-graph.sh +3 -3
  24. package/payload/gate-sdk/checks/check-reads-couples.sh +3 -1
  25. package/payload/gate-sdk/checks/check-tree-terms.sh +11 -7
  26. package/payload/gate-sdk/lib/gate.sh +29 -13
  27. package/payload/lifecycle-kit/SPEC.md +14 -4
  28. package/payload/lifecycle-kit/templates/lead.md +38 -3
  29. package/payload/site-kit/README.md +12 -5
  30. package/payload/site-kit/SPEC.md +284 -28
  31. package/payload/site-kit/checks/check-docs-render-fidelity.sh +100 -27
  32. package/payload/site-kit/gate-tests/check-docs-render-fidelity-batch.test.sh +158 -0
  33. package/payload/site-kit/lib/site.sh +16 -2
  34. package/payload/site-kit/templates/site-health.yml +128 -6
@@ -10,17 +10,29 @@ the other.
10
10
 
11
11
  ## The monitor boundary
12
12
 
13
- A gate verifies the tree: it is deterministic, hermetic, and reds only on a
14
- cause a commit produced, which is what lets it block a merge without false
15
- positives. A live-site probe is none of those — it reds on DNS, a Pages
16
- incident, or a stalled certificate renewal, none of which any commit caused.
17
- Enforcing deployment truth through a pre-commit or CI gate would break both the
18
- low-false-positive contract and the CI backstop's checkout-plus-bash
19
- hermeticity (gate-sdk/SPEC.md §Enforcement tiers). So the deployment probe is
20
- *monitoring*, not a gate: it ships as `templates/site-health.yml`, a scheduled
21
- workflow a consumer copies, and signals through an issue and a red run of its
22
- own, never a blocked merge. The tree-honesty half — that the repo never *cites*
23
- a stale host — is a real gate, because that is a property of the tree.
13
+ **The line is where the asserted object lives.** A gate asserts over the tree: a
14
+ checkout plus bash is all it needs, which is what makes it deterministic,
15
+ hermetic, and safe to block a merge with. Deployment truth is in no checkout —
16
+ the live host's responses, its certificate, and the bodies of the Releases it
17
+ publishes are state no commit contains — so no gate can assert it, and enforcing
18
+ it through a pre-commit or CI gate would break both the low-false-positive
19
+ contract and the CI backstop's checkout-plus-bash hermeticity
20
+ (gate-sdk/SPEC.md §Enforcement tiers).
21
+
22
+ Object location governs rather than *whether a commit caused the failure*, and
23
+ the difference is load-bearing. Some host-side failures are caused by nothing any
24
+ commit did — DNS, a Pages incident, a stalled certificate renewal. Others are
25
+ caused by a session skipping a step, which is commit-shaped in spirit and still
26
+ ungateable, because the artifact it damaged sits on the host rather than in the
27
+ tree. A criterion built on cause admits the first kind and stumbles on the
28
+ second; a criterion built on where the object lives covers both, and stays true
29
+ of every probe arm instead of only the arms whose causes it happens to list.
30
+
31
+ So the deployment probe is *monitoring*, not a gate: it ships as
32
+ `templates/site-health.yml`, a scheduled workflow a consumer copies, and signals
33
+ through an issue and a red run of its own, never a blocked merge. The
34
+ tree-honesty half — that the repo never *cites* a stale host — is a real gate,
35
+ because that is a property of the tree.
24
36
 
25
37
  ## Layout and configuration
26
38
 
@@ -46,14 +58,39 @@ told to load but cannot find. Knobs:
46
58
  aliases, and dated posts are immutable published artifacts.
47
59
  - `SITE_KIT_DOCS_DIR` — the docs-site root `check-docs-render-fidelity` walks
48
60
  for tracked markdown pages, default `docs`.
49
- - `SITE_KIT_RENDERER` — array, the stdin→stdout GFM-to-HTML command
50
- `check-docs-render-fidelity` renders each page through, default the kramdown
51
- CLI invocation with GFM input — `ruby -e '…Kramdown::Document…input: "GFM"…'`,
52
- the parser GitHub Pages pins. A consumer whose Pages stack differs points this
61
+ - `SITE_KIT_RENDERER` — array, the stdin→stdout **single-document** GFM-to-HTML
62
+ command, default the kramdown CLI invocation with GFM input —
63
+ `ruby -e '…Kramdown::Document…input: "GFM"…'`, the parser GitHub Pages pins.
64
+ It is the contract `check-docs-render-fidelity` renders each page through when
65
+ `SITE_KIT_RENDERER_BATCH` is empty: one of the gate's two renderer contracts,
66
+ and the fallback of the pair. A consumer whose Pages stack differs points this
53
67
  at its own renderer; an unresolvable one fails the gate closed.
68
+ - `SITE_KIT_RENDERER_BATCH` — array, **optional**: a command rendering N
69
+ documents over one stream, `NUL`-terminated in both directions and
70
+ count-preserving, the framing specified in §check-docs-render-fidelity. Setting
71
+ it collapses the gate's per-page interpreter restarts into a single process,
72
+ which is where substantially all of that gate's cost lives. Its default is the
73
+ batch form of the same kramdown-with-GFM-input invocation `SITE_KIT_RENDERER`
74
+ defaults to — a `ruby -e` loop splitting stdin on `NUL` and writing one
75
+ `NUL`-terminated HTML document per input — filled **only when
76
+ `SITE_KIT_RENDERER` is itself still at its kit default.** Filling it
77
+ unconditionally would defeat a deliberate pin: a consumer who points
78
+ `SITE_KIT_RENDERER` at the version-locked bundle below, not knowing a second
79
+ knob now exists, would have that pinned oracle replaced by this unpinned one
80
+ and the gate would report clean against a parser build they explicitly
81
+ rejected — a false clean produced by an upgrade. Under the rule they instead
82
+ keep the per-document path at its own cost and its own semantics, and opt in by
83
+ pointing this knob at the batch form of their own pinned renderer.
54
84
  - `SITE_KIT_CONFIG_FILE` — the loader override; when set it must resolve, else
55
85
  the gate exits 2 rather than silently run on defaults.
56
86
 
87
+ `templates/site-health.yml` is governed by none of these. Its knobs — `ALT_DOMAIN`
88
+ and the three `RELEASE_NOTE_*` below — are **step-level workflow env** set in the
89
+ copied file itself, not `SITE_KIT_*` knobs, and `lib/site.sh` never loads them.
90
+ The template is copied and edited rather than sourced, so reaching into the gate
91
+ config loader would couple a monitor to the gates dir and hard-code a vendored
92
+ kit path into a workflow whose whole distribution model is verbatim copy.
93
+
57
94
  ## check-docs-cname-parity
58
95
 
59
96
  Invariant: no tracked file cites a `SITE_KIT_ALIASES` host in a `://` URL,
@@ -165,6 +202,49 @@ consumer registers this gate; it stays outside env-probe's probe-set floor, and
165
202
  published docs site simply omits the gate by the registry-not-array convention
166
203
  and never installs the dependency.
167
204
 
205
+ **The batch stream, and why the count is the fail-closed.** One renderer process
206
+ per page is the gate's whole cost — the interpreter restarts, not the rendering —
207
+ so where `SITE_KIT_RENDERER_BATCH` is non-empty the gate renders the corpus over
208
+ one stream instead. The framing is `NUL`-terminated in both directions: the gate
209
+ writes each front-matter-stripped body, `NUL`-terminated, to the command's stdin,
210
+ and the command writes each rendered document to stdout in the **same order**,
211
+ each `NUL`-terminated. `NUL` is a *terminator* rather than a separator, so N
212
+ documents produce exactly N `NUL`s with no trailing-empty ambiguity, and it is
213
+ unforgeable by page content for a stronger reason than rarity: bash cannot hold a
214
+ `NUL` in a variable, so the gate's own reader has already dropped any `NUL` in
215
+ the source before framing happens. A sentinel line would be forgeable — by a docs
216
+ page describing this contract, first of all. Length-prefixed framing is equally
217
+ sound and loses only on the obligation it puts on a consumer, who would have to
218
+ implement exact-byte reads where splitting on a byte is a one-liner in every
219
+ language a Pages stack might use.
220
+
221
+ Two implementation constraints follow, and a natural reading of the contract
222
+ breaks both. **Command substitution strips `NUL`**, so the batch output must
223
+ never pass through `$(…)`; the gate reads it through a **process substitution**
224
+ instead, which also keeps the loop body in the current shell so the findings it
225
+ appends to survive. Writer and reader being separate processes
226
+ is what makes the exchange deadlock-free. **Process substitution discards the
227
+ renderer's exit status**, so the batch path cannot keep the per-page fail-closed
228
+ the per-document loop has — and a renderer that dies mid-stream yields fewer
229
+ documents than pages. The gate therefore compares documents-read against
230
+ pages-enumerated after the loop, which detects renderer death, truncation and
231
+ framing error alike, one check standing in for the status the shell threw away.
232
+ It exits 2 — a refusal to run the oracle — never 1, which would report a finding
233
+ about the docs. Per-document scanning is unchanged: each document read off the
234
+ stream goes through the same assertions, and the source-side scans are untouched.
235
+
236
+ **Probe routing.** The gate probes the oracle it will actually run, and only that
237
+ one. With the batch knob empty it probes `SITE_KIT_RENDERER` on a one-line
238
+ document exactly as above. With the batch knob set it probes the batch command
239
+ instead, on a probe that exercises the framing as well as the parser: two
240
+ one-line documents in, exactly two non-empty documents back. Probing the
241
+ per-document renderer too would refuse a batch-only consumer over a renderer this
242
+ run never invokes. A **failing** batch probe exits 2 and does not fall back: a
243
+ set knob is the consumer's deliberate statement about which parser is
244
+ authoritative, so quietly rendering through a different one is the same
245
+ false-clean class the fill condition in §Layout and configuration closes from the
246
+ other direction. A gate that cannot run its configured oracle refuses.
247
+
168
248
  The false-positive floor is the assertion's hard boundary, deliberately set. The
169
249
  backtick symptom rests on a property of well-formed markdown: every backtick
170
250
  belongs to a code span, which renders inside `<code>` and is excluded from the
@@ -214,9 +294,18 @@ test isolating it — a page with no fence, no surplus heading and no table, who
214
294
  only defect is the severed span, reds span-only and clears in the
215
295
  doubled-backtick form — so a widening that reds nothing new cannot pass. The
216
296
  table assertion likewise carries its own unit test (a collapsed table reds
217
- table-only, a trailing blank clears).
297
+ table-only, a trailing blank clears). The batch contract carries a unit test of
298
+ its own for the same reason — the good/bad pair sets no renderer knob, so it
299
+ already runs the batch path and cannot by itself distinguish that path from the
300
+ fallback. That test asserts the kit's two renderer defaults render a corpus
301
+ byte-identically, that a pinned `SITE_KIT_RENDERER` suppresses the batch default,
302
+ that the batch path and the per-document fallback return the same verdict on the
303
+ same pages, and that a wrong document count and an unresolvable batch command
304
+ each exit 2. The count case uses a stub that always emits two documents, so it
305
+ passes the two-document probe and is caught only by the corpus count — a stub the
306
+ probe already rejected would never reach the assertion under test.
218
307
  The positional form `check-docs-render-fidelity.sh [docs-dir] [config-file]`
219
- lets a fixture point the docs dir and renderer at a synthetic tree without
308
+ lets a fixture point the docs dir and renderer knobs at a synthetic tree without
220
309
  touching consumer config. `precommit` tier, coupling the docs tree.
221
310
 
222
311
  Parser-version fidelity (a second honest limit). The oracle is faithful to the
@@ -228,35 +317,202 @@ introduced between the two versions. The exact-pin recipe closes that gap for a
228
317
  consumer that needs it: point `SITE_KIT_RENDERER` at a version-locked bundle —
229
318
  a `bundle exec ruby …Kramdown…` invocation whose `Gemfile.lock` pins kramdown
230
319
  (and `kramdown-parser-gfm`) to the versions the `github-pages` gem resolves — so
231
- the oracle and the deploy render byte-for-byte the same parser build. The kit
232
- does not auto-resolve that pin: fetching the Pages-locked gemset at gate time
233
- would break the hermetic no-network render contract the oracle depends on (a
234
- gate must run offline and deterministically), so the pin stays a consumer's
235
- deliberate `SITE_KIT_RENDERER` override, not kit-run machinery.
320
+ the oracle and the deploy render byte-for-byte the same parser build. Pin
321
+ `SITE_KIT_RENDERER_BATCH` in the same motion, at the batch form of that same
322
+ locked bundle, or leave it unset: those are the two states in which the gate runs
323
+ the parser build the pin names. Overriding only the per-document knob already
324
+ leaves the batch knob empty by its fill rule, so a half-applied pin costs speed
325
+ rather than fidelity — but a consumer who set a batch renderer earlier and pins
326
+ only the per-document one afterwards has pinned the knob the gate will not use.
327
+ The kit does not auto-resolve the pin: fetching the Pages-locked gemset at gate
328
+ time would break the hermetic no-network render contract the oracle depends on (a
329
+ gate must run offline and deterministically), so it stays a consumer's deliberate
330
+ override, not kit-run machinery.
331
+
332
+ Renderer agreement (a third honest limit). Where a consumer sets both renderer
333
+ knobs, the kit cannot verify that their batch renderer agrees document-for-
334
+ document with their per-document one; a divergent pair yields a divergent oracle,
335
+ and nothing in the framing contract can detect that. What the kit does hold is
336
+ its own pair: the two defaults are asserted byte-identical over a corpus by
337
+ fixture, so the zero-config path is covered by construction rather than by
338
+ assumption.
236
339
 
237
340
  ## lib/site.sh
238
341
 
239
342
  The sourced config loader: it loads `SITE_KIT_CONFIG_FILE` (or the gates-dir
240
- `site-config.sh` when that env is unset), then fills every knob's default, so a
343
+ `site-config.sh` when that env is unset), then fills each knob's default, so a
241
344
  gate and a fixture read one resolved configuration. It carries no gate logic —
242
345
  structure stays in the check, values in config, defaults here.
243
346
 
347
+ Every knob's default is filled whenever the consumer left it unset, with one
348
+ exception the loader is the only place to state: `SITE_KIT_RENDERER_BATCH` is
349
+ filled only where the loader also owns `SITE_KIT_RENDERER` — where the consumer
350
+ overrode neither. A consumer who overrode the per-document renderer and left the
351
+ batch knob unset gets an empty batch array instead of a default, so the gate
352
+ keeps running the oracle they chose; §Layout and configuration states the rule
353
+ with the false clean it exists to prevent.
354
+
244
355
  ## templates/site-health.yml
245
356
 
246
357
  The scheduled live-site probe, copied verbatim into a consumer's
247
358
  `.github/workflows/`. It reads the apex host from the CNAME file (the same
248
359
  source the gate trusts), then checks: the apex answers 200 over HTTPS, `www`
249
360
  and `http` redirect to the canonical origin, an optional `ALT_DOMAIN` redirect
250
- keeps its path, and the certificate is more than a fortnight from expiry. A
361
+ keeps its path, the certificate is at least a fortnight from expiry, and every
362
+ published release note is pointed at by a resolving URL in its Release body. A
251
363
  failure opens or updates a single `site-health` issue and reds the run;
252
364
  recovery closes it. The `ALT_DOMAIN` value is a bare hostname, never a `://`
253
365
  literal, so it does not itself trip the parity gate. A `# enforce:` marker rides
254
366
  the template so that, once copied, an enforcement map projects it as a monitor.
255
367
 
256
- The template is starter-template-conformant: the kit's `smoke/install.sh`
257
- installs it verbatim as governed surface, so a regression that made it red any
258
- vendored kit's gate would surface in the consumer smoke rather than at a
259
- consumer.
368
+ The workflow's `permissions:` block is an **allowlist, not an addition** — every
369
+ scope it omits is `none` — so reading the tag list and the Release bodies needs
370
+ `contents: read` declared beside `issues: write`, and the probe step needs its own
371
+ `GH_TOKEN`. On a public repository the declaration is redundant and the arm
372
+ appears to work without it; at a private-repo consumer it is the difference
373
+ between the arm working and the arm 404ing on every note, because GitHub masks an
374
+ unauthorized read as an absent resource — the failure arrives looking like "no
375
+ such Release" rather than "not permitted". No gate parses a `permissions:` block
376
+ (workflow-security linting is an explicit non-goal, gate-sdk/SPEC.md
377
+ §check-action-run-shell), so this one is held by review rather than by an oracle.
378
+
379
+ **The release-body arm.** For every tracked release note whose front-matter tag
380
+ key names a tag that exists on the remote, the arm asserts two properties over
381
+ that tag's Release:
382
+
383
+ - **Presence** — a Release exists for the tag, and its body *contains* the note's
384
+ canonical URL, derived **scheme-qualified** as `https://` plus the apex host
385
+ from the CNAME file plus the path from `RELEASE_NOTE_URL_PATH`. This is what
386
+ catches a body that was never filled in.
387
+ - **Resolution** — every apex-hosted URL *as literally written in the body*
388
+ answers 200. This is what catches a body whose pointer is present but dead.
389
+
390
+ **The two run over two different strings, and collapsing them re-opens the defect
391
+ the other closes.** A body carrying a trailing-slash URL *contains* the
392
+ slash-less form as a substring, so a presence-only check passes a pointer that
393
+ 404s; and a probe that derived the URL itself and then resolved *that* would
394
+ confirm only its own arithmetic while the body stayed wrong. Presence runs over
395
+ the URL the arm derives; resolution over the URLs the body actually carries.
396
+
397
+ Presence is deliberately loose in one direction and strict in the other.
398
+ *Containment, never equality*: a body may write a suffixed or otherwise decorated
399
+ variant of the URL, so a token-equality test reds a corpus that is in fact
400
+ correct — and the looseness that permits it is exactly what lets the
401
+ trailing-slash form through, which is why resolution exists rather than a
402
+ stricter presence. *Scheme-qualified*: a markdown link whose visible label
403
+ repeats the URL scheme-less satisfies a scheme-less presence test while the link
404
+ *target* goes unchecked, and a wrong-but-resolving target then passes both
405
+ assertions with nothing red.
406
+
407
+ URL extraction is **scheme-anchored over the whole body text**, never
408
+ markdown-link-aware — only the scheme reliably separates a link target from a
409
+ visible label — and a trailing **run** of punctuation is stripped from an
410
+ extracted URL before it is resolved. The punctuation that occurs in practice is
411
+ markdown-structural rather than sentential: a `)` closing a link target, or `)**`
412
+ closing one inside bold. A stripping set written for the period captures those
413
+ closers into the URL and reds a healthy corpus, so the set carries the markdown
414
+ closers alongside sentence punctuation (the template owns the set), and strips a
415
+ run rather than a single character — or `)**` merely becomes `)*`.
416
+ The extracted set is **not** narrowed to note URLs: the assertion is over
417
+ apex-hosted URLs, so a body's other apex links are covered deliberately.
418
+
419
+ The tag list comes from the **API, paginated**, never from `git tag`.
420
+ `actions/checkout` defaults to `fetch-depth: 1` and fetches no tags, so a
421
+ `git tag`-driven arm finds zero released notes and reports green forever. Two
422
+ properties of the call are load-bearing: `gh api --paginate` discharges the
423
+ paging with no manual page loop, and because it *concatenates* the pages' arrays,
424
+ `--jq 'length'` returns the last page's length rather than the total — so the
425
+ count is taken by streaming the elements, and the pagination is forward-looking
426
+ insurance no run will ever confirm until a consumer passes its first page. The
427
+ tag list is not replaceable by a per-note Release-by-tag lookup: a 404 there
428
+ cannot distinguish a tag that was never pushed (a legitimate skip for a note
429
+ whose release is deferred) from a tag whose Release is missing (a real finding),
430
+ and conflating them either reds every deferred note or hides a missing Release.
431
+
432
+ **The arm's three knobs** are step-level workflow env on the probe step, set in
433
+ the copied file the way `ALT_DOMAIN` already is (§Layout and configuration):
434
+
435
+ - `RELEASE_NOTE_GLOB` — the tracked path glob enumerating release-note files.
436
+ - `RELEASE_NOTE_TAG_KEY` — the front-matter key whose value is the tag a note
437
+ belongs to. Load-bearing rather than decorative: a posts directory holds posts
438
+ that are not release notes, and this key is what separates them. It is read
439
+ **anchored inside the opening front-matter fence**, so the same key spelled in
440
+ a note's body is not mistaken for the note's own tag.
441
+ - `RELEASE_NOTE_URL_PATH` — the site path a note is published at, written with a
442
+ `{slug}` token the arm substitutes with the note filename minus its extension.
443
+ It holds the **path only**; the host is never repeated here, because the CNAME
444
+ file stays the single source for it and a host rename must stay a one-file
445
+ edit. This is the knob with no cross-check anywhere — nothing outside the site
446
+ generator derives a note's served URL — so it is the one a consumer can set
447
+ wrongly and see nothing red. The concrete trap: a generator that emits
448
+ `/posts/<slug>.html` while the host *also* serves the extensionless form makes
449
+ the suffixed value look the more literally correct of the two, and it reds
450
+ every body written to the bare form.
451
+
452
+ **The zero-cases, ruled exhaustively.** Every count the arm ranges over can be
453
+ zero, and each zero is either a finding or a legitimate pass; an unruled one is
454
+ how the arm becomes a green that means nothing.
455
+
456
+ - **The glob matches no notes** — a **finding**. A misconfigured
457
+ `RELEASE_NOTE_GLOB` is itself the defect, which is what makes "set these knobs
458
+ or delete the arm" an instruction rather than advice.
459
+ - **The tag-list call fails** — a **finding**, asserted on the call's own exit
460
+ status with the API's error text (which carries the HTTP code) in the message,
461
+ never inferred from the count that follows. The probe step runs under `set +e`,
462
+ so a failed invocation yields an empty tag list and a zero exit; every note then
463
+ reads "not yet released" and the arm reports a clean run forever. On the
464
+ per-Release lookup a failure reads like "no such Release"; on the tag-list call
465
+ the same failure reads like "green".
466
+ - **The per-Release lookup fails for a tag that exists** — a **finding**. The tag
467
+ list has already established that the tag is real, so this is the
468
+ missing-Release case rather than the deferred-release one.
469
+ - **The glob matches notes and none carries the tag key** — **not** a finding,
470
+ stated so it is not added by symmetry with the first case. A consumer whose
471
+ notes genuinely precede its first release is in this state legitimately. It is
472
+ nonetheless the likelier of the two knob misconfigurations, precisely because
473
+ the glob's failure is loud and the key's is silent.
474
+ - **Zero *released* notes** — not a finding, for the same reason.
475
+
476
+ **The census line makes those states readable; the rulings above are what make a
477
+ vacuous pass impossible.** On every run the arm prints a census of what it ranged
478
+ over — notes found, of those carrying the tag key, of those released against the
479
+ remote tag count, and of those checked. No count in it is another by
480
+ construction: the gap between *found* and *keyed* separates a typo'd
481
+ `RELEASE_NOTE_TAG_KEY` from a corpus that simply mixes notes with ordinary posts,
482
+ the gap between *keyed* and *released* is the legitimate pre-release state, and
483
+ the gap between *released* and *checked* is a Release the arm could not read.
484
+ Collapsing *found* into *keyed* would render the first two of those states
485
+ identically, which is what reporting them apart buys. This is the same shape as
486
+ gate-sdk's vacuous-pass
487
+ tripwire (§run-gates): a *reading* available to whoever opens the run log, not an
488
+ assertion, and on a green run nobody opens it. It earns its place as the
489
+ diagnostic naming which state a reader is in; it is not itself what stands
490
+ between this arm and a vacuous pass.
491
+
492
+ **Stated coverage limit.** The arm is driven from the tree's notes, so it is total
493
+ over note→Release and silent on the reverse: a Release carrying no note anywhere
494
+ in the tree reds nowhere. The deliverable is the note's pointer, and the
495
+ population that has ever gone wrong is the pointer's.
496
+
497
+ **Cost per run.** The paginated tag list, one Release lookup per released note,
498
+ and one resolution request per distinct apex URL in each body — linear in release
499
+ count, on a daily schedule, well inside the authenticated rate limit.
500
+ Deliberately uncapped and unknobbed: a "newest N only" bound would stop probing
501
+ exactly the old releases where this class of defect has actually been found.
502
+
503
+ The kit's `smoke/install.sh` installs the template verbatim into the scratch tree
504
+ as governed surface. **What that buys is narrower than the install suggests, and
505
+ is stated here rather than inferred from it.** The scratch battery is the union of
506
+ what each kit's `smoke/install.sh` registers, and of those gates only
507
+ `check-tree-terms` and `check-docs-cname-parity` read the installed workflow at
508
+ all — one for tree terms, the other for configured host aliases in `://` form.
509
+ None of the gates that lint a workflow's *Actions shape* — its `run:` bodies, its
510
+ action pins, its `gh` repository context — is registered in any kit's smoke
511
+ `gates.list`, so none of them runs over the installed file. The smoke therefore
512
+ catches a template that leaks a term or a host alias, and nothing else about it; a
513
+ regression in the workflow's bash or its pinning surfaces at a consumer, not here.
514
+ Closing that is a change to smoke wiring rather than to this template, and is
515
+ carried as deferred work in the consumer's queue.
260
516
 
261
517
  ## Out of scope
262
518
 
@@ -4,7 +4,7 @@
4
4
  #
5
5
  # usage: check-docs-render-fidelity.sh [docs-dir] [config-file]
6
6
  # defaults SITE_KIT_DOCS_DIR; config-file overrides SITE_KIT_CONFIG_FILE so a
7
- # fixture supplies its own SITE_KIT_RENDERER / docs dir.
7
+ # fixture supplies its own renderer knobs / docs dir.
8
8
  set -uo pipefail
9
9
 
10
10
  KIT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
@@ -23,12 +23,28 @@ git rev-parse --git-dir >/dev/null 2>&1 || {
23
23
  echo "check-docs-render-fidelity: not a git repository — cannot enumerate tracked pages" >&2; exit 2; }
24
24
  [[ -d "$DOCS" ]] || { echo "check-docs-render-fidelity: docs dir not found: $DOCS" >&2; exit 2; }
25
25
 
26
- probe="$(printf '# probe\n' | "${SITE_KIT_RENDERER[@]}" 2>/dev/null)"; pst=$?
27
- if [[ "$pst" -ne 0 || -z "$probe" ]]; then
28
- echo "check-docs-render-fidelity: renderer '${SITE_KIT_RENDERER[*]}' could not run (exit $pst)" >&2
29
- echo " help: install the Pages parser — ruby plus the kramdown-parser-gfm gem — or point" >&2
30
- echo " SITE_KIT_RENDERER at a stdin->stdout GFM-to-HTML command" >&2
31
- exit 2
26
+ # spec: site-kit/SPEC.md §check-docs-render-fidelity — probe the oracle the gate will actually run, and only that one: a set batch knob is the consumer's statement of which parser is authoritative, so a batch-only setup is never refused over a per-document renderer this run will not invoke
27
+ if [[ ${#SITE_KIT_RENDERER_BATCH[@]} -gt 0 ]]; then
28
+ bprobe=0
29
+ while IFS= read -r -d '' d; do
30
+ [[ -n "${d//[[:space:]]/}" ]] && bprobe=$((bprobe + 1))
31
+ done < <(printf '%s\n\000' '# probe one' '# probe two' | "${SITE_KIT_RENDERER_BATCH[@]}" 2>/dev/null)
32
+ if [[ "$bprobe" -ne 2 ]]; then
33
+ echo "check-docs-render-fidelity: batch renderer '${SITE_KIT_RENDERER_BATCH[*]}' failed its probe" >&2
34
+ echo " (2 documents in, $bprobe non-empty document(s) back)" >&2
35
+ echo " help: SITE_KIT_RENDERER_BATCH must read NUL-terminated documents from stdin and write" >&2
36
+ echo " one NUL-terminated HTML document per input, in order; unset it to fall back to" >&2
37
+ echo " the per-document SITE_KIT_RENDERER contract" >&2
38
+ exit 2
39
+ fi
40
+ else
41
+ probe="$(printf '# probe\n' | "${SITE_KIT_RENDERER[@]}" 2>/dev/null)"; pst=$?
42
+ if [[ "$pst" -ne 0 || -z "$probe" ]]; then
43
+ echo "check-docs-render-fidelity: renderer '${SITE_KIT_RENDERER[*]}' could not run (exit $pst)" >&2
44
+ echo " help: install the Pages parser — ruby plus the kramdown-parser-gfm gem — or point" >&2
45
+ echo " SITE_KIT_RENDERER at a stdin->stdout GFM-to-HTML command" >&2
46
+ exit 2
47
+ fi
32
48
  fi
33
49
 
34
50
  listing="$(git ls-files -- "$DOCS")"; st=$?
@@ -48,15 +64,14 @@ if [[ ${#pages[@]} -eq 0 ]]; then
48
64
  exit 0
49
65
  fi
50
66
 
51
- strip_fm='NR==1 && $0=="---" { fm=1; next } fm==1 && $0=="---" { fm=0; next } fm==1 { next } { print }'
52
-
53
67
  rendered_scan='
54
68
  BEGIN {
55
- inpre=0; leak=0; h=0; tbl=0; fgn=0
56
69
  # spec: site-kit/SPEC.md §check-docs-render-fidelity — the known-HTML-element set is a kit built-in, not a config seam
57
70
  split("a abbr address area article aside audio b base bdi bdo blockquote body br button canvas caption cite code col colgroup data datalist dd del details dfn dialog div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 head header hgroup hr html i iframe img input ins kbd label legend li link main map mark menu meta meter nav noscript object ol optgroup option output p param picture pre progress q rp rt ruby s samp script search section select slot small source span strong style sub summary sup table tbody td template textarea tfoot th thead time title tr track u ul var video wbr", A, " ")
58
71
  for (i in A) HTMLEL[A[i]]=1
59
72
  }
73
+ # spec: site-kit/SPEC.md §check-docs-render-fidelity — BEGINFILE/ENDFILE (GNU awk) reset the per-page state and emit the result the instant the file ends, so one process fed every page html file reproduces what re-execing this program once per page produced
74
+ BEGINFILE { inpre=0; leak=0; h=0; tbl=0; fgn=0 }
60
75
  {
61
76
  t=$0
62
77
  while (match(t, /<h[1-6][ >]/)) { h++; t=substr(t, RSTART+RLENGTH) }
@@ -85,10 +100,10 @@ BEGIN {
85
100
  gsub(/<[^>]*>/, "", s)
86
101
  if (s ~ /`/) leak=1
87
102
  }
88
- END { print leak+0, h+0, tbl+0 }'
103
+ ENDFILE { print leak+0, h+0, tbl+0 }'
89
104
 
90
105
  source_headings='
91
- BEGIN { infence=0; fchar=""; flen=0; count=0; prevblank=1; previsatx=0 }
106
+ BEGINFILE { infence=0; fchar=""; flen=0; count=0; prevblank=1; previsatx=0 }
92
107
  {
93
108
  s=$0; n=0
94
109
  while (substr(s,1,1)==" ") { s=substr(s,2); n++ }
@@ -109,11 +124,11 @@ BEGIN { infence=0; fchar=""; flen=0; count=0; prevblank=1; previsatx=0 }
109
124
  if (n<=3 && s ~ /^#{1,6}([ \t]|$)/) { count++; prevblank=0; previsatx=1; next }
110
125
  prevblank=($0 ~ /^[ \t]*$/); previsatx=0
111
126
  }
112
- END { print count+0 }'
127
+ ENDFILE { print count+0 }'
113
128
 
114
129
  # spec: site-kit/SPEC.md §check-docs-render-fidelity — count source GFM table starts (a pipe row followed by a | --- | delimiter row) outside code fences
115
130
  source_tables='
116
- BEGIN { infence=0; fchar=""; flen=0; count=0; prevpipe=0 }
131
+ BEGINFILE { infence=0; fchar=""; flen=0; count=0; prevpipe=0 }
117
132
  {
118
133
  s=$0; n=0
119
134
  while (substr(s,1,1)==" ") { s=substr(s,2); n++ }
@@ -133,21 +148,79 @@ BEGIN { infence=0; fchar=""; flen=0; count=0; prevpipe=0 }
133
148
  if ($0 ~ /^[ \t]*$/) { prevpipe=0; next }
134
149
  prevpipe = (index($0, "|") > 0) ? 1 : 0
135
150
  }
136
- END { print count+0 }'
151
+ ENDFILE { print count+0 }'
152
+
153
+ # spec: site-kit/SPEC.md §check-docs-render-fidelity — one awk process strips front matter from every page at once (a page-indexed temp file per output, gawk's ARGIND keying the filename to the page it came from) rather than re-execing awk once per page; BEGINFILE/ARGIND are GNU awk (already the family's toolchain floor, docs/install.md)
154
+ WORK="$(mktemp -d)" || { echo "check-docs-render-fidelity: could not create a scratch dir" >&2; exit 2; }
155
+ trap 'rm -rf "$WORK"' EXIT
156
+
157
+ for i in "${!pages[@]}"; do : > "$WORK/body.$i"; done
158
+
159
+ awk -v outdir="$WORK" '
160
+ BEGINFILE { outfile = outdir "/body." (ARGIND - 1); fm = 0 }
161
+ FNR==1 && $0=="---" { fm=1; next }
162
+ fm==1 && $0=="---" { fm=0; next }
163
+ fm==1 { next }
164
+ { print > outfile }
165
+ ' "${pages[@]}"
166
+ bst=$?
167
+ fail_closed "$bst" DOCS-RENDER-FIDELITY front-matter-strip
168
+
169
+ bodies=()
170
+ body_files=()
171
+ for i in "${!pages[@]}"; do
172
+ bodies+=("$(<"$WORK/body.$i")")
173
+ body_files+=("$WORK/body.$i")
174
+ done
175
+
176
+ htmls=()
177
+ if [[ ${#SITE_KIT_RENDERER_BATCH[@]} -gt 0 ]]; then
178
+ # spec: site-kit/SPEC.md §check-docs-render-fidelity — command substitution strips NUL, so the framed stream is read through a process substitution: it never passes through $(…), and the loop body stays in this shell
179
+ while IFS= read -r -d '' html; do
180
+ while [[ "$html" == *$'\n' ]]; do html="${html%$'\n'}"; done
181
+ htmls+=("$html")
182
+ done < <(printf '%s\n\000' "${bodies[@]}" | "${SITE_KIT_RENDERER_BATCH[@]}")
183
+ # spec: site-kit/SPEC.md §check-docs-render-fidelity — the count assertion stands in for the per-page exit status process substitution discarded, so it catches renderer death, truncation and framing error alike, and refuses (2) rather than reporting a finding (1)
184
+ if [[ ${#htmls[@]} -ne ${#pages[@]} ]]; then
185
+ echo "check-docs-render-fidelity: batch renderer returned ${#htmls[@]} document(s) for ${#pages[@]} page(s)" >&2
186
+ echo " help: SITE_KIT_RENDERER_BATCH must write exactly one NUL-terminated HTML document per" >&2
187
+ echo " NUL-terminated input document, in order; a short count is a renderer that died" >&2
188
+ echo " mid-stream, truncated its output, or framed it wrongly" >&2
189
+ exit 2
190
+ fi
191
+ else
192
+ for body in "${bodies[@]}"; do
193
+ html="$(printf '%s\n' "$body" | "${SITE_KIT_RENDERER[@]}")"; rst=$?
194
+ fail_closed "$rst" DOCS-RENDER-FIDELITY renderer
195
+ htmls+=("$html")
196
+ done
197
+ fi
198
+
199
+ # spec: site-kit/SPEC.md §check-docs-render-fidelity — each of the three per-page scans batches into one awk process across every page's file (gawk's ENDFILE emits the scan's result line the instant a file finishes, in ARGV order, so one process substitution-free command substitution yields one result line per page) rather than re-execing awk once per page per scan
200
+ html_files=()
201
+ for i in "${!pages[@]}"; do
202
+ printf '%s\n' "${htmls[$i]}" > "$WORK/html.$i"
203
+ html_files+=("$WORK/html.$i")
204
+ done
205
+
206
+ rscan_out="$(awk "$rendered_scan" "${html_files[@]}")"; ast=$?
207
+ fail_closed "$ast" DOCS-RENDER-FIDELITY rendered-scan
208
+ mapfile -t rscan_lines <<< "$rscan_out"
209
+
210
+ heading_out="$(awk "$source_headings" "${body_files[@]}")"; sst=$?
211
+ fail_closed "$sst" DOCS-RENDER-FIDELITY source-scan
212
+ mapfile -t heading_lines <<< "$heading_out"
213
+
214
+ table_out="$(awk "$source_tables" "${body_files[@]}")"; tst=$?
215
+ fail_closed "$tst" DOCS-RENDER-FIDELITY source-table-scan
216
+ mapfile -t table_lines <<< "$table_out"
137
217
 
138
218
  findings=()
139
- for page in "${pages[@]}"; do
140
- body="$(awk "$strip_fm" "$page")"; bst=$?
141
- fail_closed "$bst" DOCS-RENDER-FIDELITY front-matter-strip
142
- html="$(printf '%s\n' "$body" | "${SITE_KIT_RENDERER[@]}")"; rst=$?
143
- fail_closed "$rst" DOCS-RENDER-FIDELITY renderer
144
-
145
- read -r leak rcount rtbl < <(printf '%s\n' "$html" | awk "$rendered_scan"); ast=$?
146
- fail_closed "$ast" DOCS-RENDER-FIDELITY rendered-scan
147
- scount="$(printf '%s\n' "$body" | awk "$source_headings")"; sst=$?
148
- fail_closed "$sst" DOCS-RENDER-FIDELITY source-scan
149
- stbl="$(printf '%s\n' "$body" | awk "$source_tables")"; tst=$?
150
- fail_closed "$tst" DOCS-RENDER-FIDELITY source-table-scan
219
+ for i in "${!pages[@]}"; do
220
+ page="${pages[$i]}"
221
+ read -r leak rcount rtbl <<< "${rscan_lines[$i]}"
222
+ scount="${heading_lines[$i]}"
223
+ stbl="${table_lines[$i]}"
151
224
 
152
225
  [[ "$leak" -eq 1 ]] && findings+=("$page: a code-span corruption symptom (a stray backtick, or a raw non-HTML-element tag) leaked into rendered text — a code span or fenced block failed to parse")
153
226
  [[ "$rcount" -gt "$scount" ]] && findings+=("$page: $rcount rendered heading(s) exceed $scount source heading(s) outside code — a code-fenced '#' line was promoted")